Algorithm 二叉树的高度是否正确?
高个子们,上面的树有多高?是3点对吗 我的老师设计的测试用例预计是2个 这是我用来获取高度的代码Algorithm 二叉树的高度是否正确?,algorithm,binary-tree,Algorithm,Binary Tree,高个子们,上面的树有多高?是3点对吗 我的老师设计的测试用例预计是2个 这是我用来获取高度的代码 public int height(TreeNode t){ if (t == null) return 0; int heightLeft = height(t.leftChild); int heightRight = height(t.rightChild) if( heightLeft > heightRight ) return heightLeft +1; else retur
public int height(TreeNode t){
if (t == null)
return 0;
int heightLeft = height(t.leftChild);
int heightRight = height(t.rightChild)
if( heightLeft > heightRight )
return heightLeft +1;
else
return heightRight +1;
}
为什么要关闭此线程??
树的深度(或高度)是从根到树中最深节点的路径长度。只有一个节点(根)的(根)树的深度为零
你得到的是反对票,因为10秒的谷歌搜索将得到你的答案