Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm 二叉树的高度是否正确?_Algorithm_Binary Tree - Fatal编程技术网

Algorithm 二叉树的高度是否正确?

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

高个子们,上面的树有多高?是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
return heightRight +1;
}
为什么要关闭此线程??

树的深度(或高度)是从根到树中最深节点的路径长度。只有一个节点(根)的(根)树的深度为零


你得到的是反对票,因为10秒的谷歌搜索将得到你的答案