int TreeDepth(BinaryTreeNode* pRoot)
{
if(pRoot==nulllptr)
return 0;
int nLeft=TreeDepth(pRoot->m_pLeft);
int nRight=TreeDepth(pRoot->m_pRight);
return(nLeft>nRight)?(nLeft+1):(nRight+1);
}
二叉树的深度
最新推荐文章于 2024-02-22 12:51:35 发布