给定一个组值如何建立二叉树

来源:百度知道 编辑:UC知道 时间:2024/06/02 00:16:49

不太懂你的问题是什么意思?下面是我的一个先序递归调用创建二叉树的函数,希望对你有用!
//二叉树的创建
status CreateBiTree(BiTree *T)
{// 先序创建
TelemType ch;
scanf("%c",&ch);
if(ch==ENDFLAG) *T=NULL;
else {
if(!(*T=(BiTNode *)malloc(sizeof(BiTNode))))
{
printf("\nOut of space.");
getch();
exit(0);
}
(*T)->data=ch; //生成根结点
CreateBiTree(&((*T)->lchild));//左子树
CreateBiTree(&((*T)->rchild));//右子树
}
return OK;
}