1.求二叉树的深度
int TreeDepth(binary_Tree* pRoot) { if(pRoot==NULL) return 0; int nLeft=TreeDepth(pRoot->left); int nRight=TreeDepth(pRoot->right); return (nLeft>nRight) ? (nLeft+1):(nRight+1) }
时间: 2024-10-08 11:13:09
1.求二叉树的深度
int TreeDepth(binary_Tree* pRoot) { if(pRoot==NULL) return 0; int nLeft=TreeDepth(pRoot->left); int nRight=TreeDepth(pRoot->right); return (nLeft>nRight) ? (nLeft+1):(nRight+1) }