求节点个数:
int NodeCount(BiTree tree)
{
if(tree==NULL)
{
return 0;
}
else return NodeCount(tree->lchild)+NodeCount(tree->rchild)+1;
}
求叶子结点个数:
int YNodeCount(BiTree tree)
{
if(tree==NULL) return 0;
if(tree->lchild==NULL&&tree->rchild==NULL) return 1;
return YNodeCount(tree->lchild)+YNodeCount(tree->rchild);
}
树的深度:(返Depth(T))
int Depth(BiTree T)
{
int m,n;
if(T==NULL) return 0;
else
{
m=Depth(T->lchild);
n=Depth(T->rchild);
if(m>n) return (m+1);
else return (n+1);
}
}
: