Tree Terminology: Height

  • Define tree-related terminologies.

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

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

We can recursively define the height of a node:

$$ \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.