int depth(BTree root)
{
int ldepth, rdepth;
if (!root)
{
return 0;
}
else
{
ldepth = depth(root->lchild);
rdepth = depth(root->rchild);
return ldepth > rdepth ? ldepth + 1; rdepth + 1;
}
}
二叉树的深度排序算法
最新推荐文章于 2023-01-11 22:28:06 发布
int depth(BTree root)
{
int ldepth, rdepth;
if (!root)
{
return 0;
}
else
{
ldepth = depth(root->lchild);
rdepth = depth(root->rchild);
return ldepth > rdepth ? ldepth + 1; rdepth + 1;
}
}