树的高度与深度是不一样的概念:
-
The depth of a node is the number of edges from the node to the tree's root node.
A root node will have a depth of 0. -
The height of a node is the number of edges on the longest path from the node to a leaf.
A leaf node will have a height of 0.
但有时候不同书上对只有一个根节点的数的深度有不同的说法,有的认为是0(上例即是),有的认为是1。题目如果涉及到root的深度,应该会给出。