//计算二叉树的深度
int treeDepth(BiTree T)
{
if (T == NULL)
{
return 0;
}
int l = treeDepth(T->lchild);
int r = treeDepth(T->rchild);
return l > r ? l + 1 : r + 1;
}
计算二叉树的深度(C/C++)
于 2023-10-05 20:50:34 首次发布
//计算二叉树的深度
int treeDepth(BiTree T)
{
if (T == NULL)
{
return 0;
}
int l = treeDepth(T->lchild);
int r = treeDepth(T->rchild);
return l > r ? l + 1 : r + 1;
}