Minimum Depth of Binary Tree 二叉树的最小深度 ; 树的根节点到叶子节点的最小距离
As already discussed in the comments, to make things simple, you can add entries to the array to make its size a power of two, so the binary tree has the same depth for all leaves.
在评论中已经讨论的,使事情变得简单,你可以添加条目到阵列使其大小两个电源,所以二进制树的所有的叶子,相同的深度。
Write a function to find the depth of a binary tree.
写个程序找到一个二叉树的深度。
For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.
对于这个问题,一个高度平衡的二叉树是指每个节点的两个子节点的深度的差异都不超过1的二叉树。
应用推荐