设二叉树以二叉链表方式存储 试完成下列问题的递归算法。 设二叉树结点和二叉树结构体定义如下: t
已帮助 人
设二叉树以二叉链表方式存储,试完成下列问题的递归算法。 设二叉树结点和二叉树结构体定义如下: typedef struct btnode { ElemType element; struct btnode* lchild, *rchild; }BTNode; typedef struct binarytree{ BTNode* root; }BinaryTree; (1)求一棵二叉树的高度; int Depth(BTNode *p) { int lh, rh; if (!p) return 0; lh = ______________; rh = _____________; if (lh > rh) return _________; else return ________; } int DepthofBT(BinaryTree Bt) { return ___________; } (2)求一棵二叉树中的结点个数; int Size(BTNode * p) { if (!p)

回答
共1条回复-
V isit(t ->data ),!QueueEmpty ( Q ),V isit(p->lchild ->data ),p->rchild
