//求二叉树的深度
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;
}
【二叉树】求树的高度(深度)
最新推荐文章于 2021-05-03 09:46:15 发布