在大话数据结构的二叉树中,二叉树的创建方法CreateBiThrTree这个递归没有结束条件呐,看了很久,愣是找不到结束条件。代码是正规的大话数据结构的代码,麻烦各位大神给看下。
Status createBiThrTree(BiThrTree *T){
TElemType a;
scanf("%c",&a);
if(a == Nil){
*T = NULL;
}else{
*T = (BiThrTree)malloc(sizeof(BiThrNode));
if(!(*T)){
return ERROR;
}
(*T)->data = a;
createBiThrTree(&(*T)->lchild);
if((*T)->lchild){
(*T)->LTag = Link;
}
createBiThrTree(&(*T)->rchild);
if((*T)->rchild){
(*T)->RTag = Link;
}
}
return OK;
}
Status createBiThrTree(BiThrTree *T){
TElemType a;
scanf("%c",&a);
if(a == Nil){
*T = NULL;
}else{
*T = (BiThrTree)malloc(sizeof(BiThrNode));
if(!(*T)){
return ERROR;
}
(*T)->data = a;
createBiThrTree(&(*T)->lchild);
if((*T)->lchild){
(*T)->LTag = Link;
}
createBiThrTree(&(*T)->rchild);
if((*T)->rchild){
(*T)->RTag = Link;
}
}
return OK;
}

