LOGBOOK

HELP

Quiz Entry - updated: 2026.11.26

Why does the AVL rule guarantee a height of $O(\log n)$?

Because even the sparsest AVL tree of height $h$ needs $N(h) = 1 + N(h-1) + N(h-2)$ nodes, which grows like the Fibonacci numbers, i.e. exponentially in $h$. Turned around, $n$ nodes allow a height of at most about $1.44 \log_2 n$.

The sparsest AVL trees of heights 1 to 4, with 2, 4, 7 and 12 nodes

* Each sparsest tree is a root over the two previous ones, which is the Fibonacci recurrence drawn as trees. *

Ask the opposite question: what is the fewest nodes an AVL tree of height $h$ can have? To be as sparse as possible, the root has one subtree of height $h-1$ (it needs one, to reach height $h$) and the other as low as the rule allows, $h-2$. Both subtrees are themselves sparsest trees, so

$$N(h) = 1 + N(h-1) + N(h-2), \qquad N(0) = 1,\ N(1) = 2$$

giving 1, 2, 4, 7, 12, 20, 33, … , each one Fibonacci number minus 1. Fibonacci numbers grow by a factor of about 1.618 per step, so $N(h)$ is exponential in $h$. Taking the logarithm turns that into the bound: a tree with $n$ nodes has height below roughly $1.44 \log_2 n$.

So an AVL tree with a million keys is at most about 28 levels deep (a perfect tree would be 20). That is the whole point: search, insert and remove all walk one root-to-leaf path, and that path is guaranteed short.

Go deeper:

From Quiz: ADS / AVL Trees and Splay Trees | Updated: Nov 26, 2026