1 //二叉排序树 插入 (纯C语言实现) 2 BTNode * BSTInsert2(BTNode *bt,int key){ 3 //为什么纯C语言实现中 4 if(bt==NULL){ //要写成 bt->rchild=BSTInsert2(bt->lchild,key); 5 bt = (BTNode*)malloc(sizeof(BTNode)); //而不是直接 BSTInsert2(bt->lchild,key);或者是 6 bt->lchild =bt ->rchild =NULL; // bt= BSTInsert2(bt->lchild,key); ??????? 7 bt->data = key; 8 }else if(bt->data>key) 9 bt->lchild=BSTInsert2(bt->lchild,key); //函数中的形参中(BTNode *bt,int key)的BTNode *bt 10 else if(bt->data<key) //每次调用都是复制,可以理解为是一个新的树 11 bt->rchild=BSTInsert2(bt->rchild,key); //没有改变外界的实参bt 12 return bt; 13 }