Tree Terminology: Height

  • Define tree-related terminologies.

The height of a node nn is the length of a longest path from nn to a leaf.

The height of a tree is the height of its root.

We can recursively define the height of a node:

height(n)={0n=leaf1+max(height of children)nleaf} \text{height}(n)=\left \{ \begin{matrix} 0 & n = \text{leaf} \\ 1 + \max(\text{height of children}) & n \neq \text{leaf} \end{matrix} \right \}

Aside: In some references, the height of a node includes the node. In that case, the height of a leaf is 1.