//二叉树遍历算法的应用
//1、计算二叉树的深度
int Depth(BitTree T){
if(T==NULL)return 0;//如果是空树,返回0
else{
m=Depth(T->lchild);
n=Depth(T->rchild);
if(m>n)return m+1;
else return n+1;
}
}
//2、计算二叉树节点总数
int NodeCount(BitTree T){
if(T==NULL)return 0;
else
return LeadCount(T->lchild)+LeadCount(T->rchild)+1;
}
//3、计算二叉树的叶子节点数
int LeadCount(BitTree T){
if(T==NULL)return 0;
if(T->lchild==NULL&&T->rchild==NULL)return 1;//如果是叶子节点返回1
else{
return LeadCount(T->lchild)+LeadCount(T->rchild);
}
}