p*8
1 楼
今天看career up 150题的时候做到平衡树的题目。
他是这样描述的
Implement a function to check if a tree is balanced For the purposes of this
question, a balanced tree is defined to be a tree such that no two leaf
nodes differ in distance from the root by more than one.
想请问大家下边这样的算是平衡吗?因为我记得以前的定义是说每个结点的左右子树深
度之差不超过1。下边的这棵树好像不符合这个定义但是符合150题上的描述吧。
1
2
3
4
这样的呢?谢谢大家了。
1
2 3
4 5 6 7
8 9 10 11
12
他是这样描述的
Implement a function to check if a tree is balanced For the purposes of this
question, a balanced tree is defined to be a tree such that no two leaf
nodes differ in distance from the root by more than one.
想请问大家下边这样的算是平衡吗?因为我记得以前的定义是说每个结点的左右子树深
度之差不超过1。下边的这棵树好像不符合这个定义但是符合150题上的描述吧。
1
2
3
4
这样的呢?谢谢大家了。
1
2 3
4 5 6 7
8 9 10 11
12