二叉排序树的存储结构定义为以下类型:
typedef int KeyType;
typedef struct node
{KeyType key; /*关键字项*/
InfoType otherinfo; /*其它数据项*/
struct node *1child, *rchild; /*左、右孩子指针*/
} BSTNode, *BSTree;
阅读算法f33,并回答问题:
(1)对如图所示的二叉排序树T,写出f33(T,8)返回的指针所指结点的关键字;
(2)在哪些情况下算法f33返回空指针?
(3)简述算法f33的功能。
BSTNode *f33(BSTree T, KeyType x)
{ BSTNode *p;
if (T= =NULL) return NULL;
p=f33(T->1child, x);
if (p!=NULL)return p;
if (T->key>x)return T;
return f33(T->rchild, x);
}
订单号:
遇到问题请联系在线客服
订单号:
遇到问题请联系在线客服