请用C语言编写一个函数,实现求二叉树高度的算法,并给出结点结构
来源:百度知道 编辑:UC知道 时间:2024/06/14 08:01:06
快点呀!一会就考了!
typedef int Status;
typedef char TElemType;
typedef struct BiTNode{
TElemType data;
struct BiTNode *lchild,*rchild;
}BiTNode,*BiTree;
int GetDepth(BiTree T){
if(!T) return 0;
else{
int depthLeft = GetDepth( T->lchild );
int depthRight= GetDepth( T->rchild );
return (depthLeft>depthRight?depthLeft:depthRight)+1;
}
}