//求二叉树的深度
int GetDepth(bnode *root)
{
if(root == NULL)
{
return 0;
}
int leftDepth = GetDepth(root->pLeft);
int rightDepth = GetDepth(root->pRight);
return (leftDepth > rightDepth ? leftDepth : rightDepth) + 1;
}
【二叉树】求树的高度(深度)
最新推荐文章于 2022-04-20 18:27:07 发布