早教吧 育儿知识 作业答案 考试题库 百科 知识分享

计算一棵二叉树的高度,请将下列算法填空完整.intHeight(Btree*t){inth1,h2;if(t==NULL)return0;elseif()return1;else{Return(h1>h2?h1:h2)+1;}}

题目详情
计算一棵二叉树的高度,请将下列算法填空完整.
int Height(Btree *t)
{ int h1,h2;
if(t==NULL)
return 0;
else if ( )
return 1;
else
{
Return (h1>h2?h1:h2)+1;
}
}
▼优质解答
答案和解析
...
if( h1 = Height(t->left),h2 =Height(t->right),h1==h2 && h1 == 0 )
...
//// left ,right 左右子节点指针