1)偏斜的二叉樹不是100%普遍的常用術語(甚至谷歌也會感到困惑)。搜索您的講義或書籍以了解它們的含義。
-
To test is a tree has as many leves as nodes, you could just use
the function you already have that counts levels and another
function to count the number of nodes.
However, you should be abe to make another, more efficient,
algorithm that terminates earlier if if finds that the number of
nodes cannot be the same as the number of levels.
-
The depth function is correct. After all, isn't this taken
straight from the definition of tree depth?
(the only possible nitpick is the depth(null) = 1. Just be sure
you don't need depth(null) = 0 instead)