-->
当前位置:首页 > 题库 > 正文内容

程序填空题:Hight of a Binary Tree

Luz2年前 (2022-11-16)题库396
The function Height is to find the height of a binary tree T. The height of a leaf node is defined to be 0.

The tree structure is defined as the following:


typedef struct Node *PtrToNode;
struct Node{
int Data;
PtrToNode Left, Right;
};
typedef PtrToNode Tree;


Please fill in the blanks.

c++
int Height( Tree T )
{
int left_H, right_H;

if (T==NULL) return ;
left_H = Height(T->Left);
;
return ( max(left_H, right_H) + 1 );
}









答案:
第1空:-1

第2空:right_H = Height(T->Right)

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。