递归求解二叉树的高度
等于左右子树的最大高度+1
template<typename elemType>
int BinaryTree<elemType>::height(nodeType<elemType> *p)
{
if( p == NULL)
{
return 0;
}
else
{
return 1 + max( height(p->llink),height(p->rlink)); //加上根节点1层..
}
}
//辅助max
template<typename elemType>
int BinaryTree<elemType>::max(int x, int y)
{
return ( x >= y ? x : y );
}