⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 insert.c

📁 Trees are natural structures for representing certain kinds of hierarchical data. A (rooted) tree co
💻 C
字号:
#include <stdio.h>#include "Tree.h"void insertTree( TreeElementType E, Tree *T )/*  pre: T is a binary search tree *//* post: E is in T and T is still a binary search tree *//* NB. T is a reference parameter and the tree is changed as a side-effect */ { if( *T == NULL )    { *T = (Tree)malloc(sizeof(Node)); /*new leaf*/      (*T)->left = (*T)->right = (Tree)NULL;                  /*L*/      TreeElementMove(E, &((*T)->elt));                       /*.*/    }                                                         /*A*/   else/*T not NULL*/                                         /*l*/      if( TreeElementLess( E, (*T)->elt) )                    /*l*/         insertTree( E, &((*T)->left) );                      /*i*/      else if( TreeElementLess((*T)->elt, E) )                /*s*/         insertTree( E, &((*T)->right) );                     /*o*/   /* else  equal, in this implementation do nothing */       /*n*/ }/*insertTree*//* Insert a New Element E into a Binary Search Tree T. */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -