问题 问答题


以二叉链表为存储结构,分别实现二叉树的下列运算:

PARENT(BT,X);

答案

参考答案:

解析:bitreptr parent(bitreptr BT,p; datatype x) /*调用前P为空指针*/ { if(BT!=NULL) if(BT—>data==X)return(p) /*找到,返回其父结点*/ else{p=BT; parent(BT—>lchild,p-,x); /*查找其左子树*/ parent(BT—>rchild,p,x); /*查找其右子树*/ } }

单项选择题
单项选择题