【正确答案】二叉树是递归定义的,以递归方式建立最简单。二叉树建立过程如下:
BiTree Creat(){ //建立二叉树的二叉链表形式的存储结构
ElemType x;
BiTree bt;
scanf("%d", &x); //本题假定结点数据域为整型
if(x==0) bt=null;
else if(x>0){
bt=(BiNode*)malloc(sizeof(BiNode));
bt->data=x;
bt->lchild=Creat();
bt->rchild=Creat();
}
else error("输入错误");
return(bt);
}//结束BiTree
【答案解析】