II · Trees, with shape

AVL tree

Always height-balanced, to within one.

The story

Two Soviet computer scientists (the V in AVL is for Velsky) published the first self-balancing BST. The constraint: at every node, the heights of the two subtrees differ by at most one. The result: log-base-φ depth, the tightest balance bound of any common tree.

How it works

After every insert/delete, rotate to restore the height-difference invariant. There are four rotation cases (LL, LR, RL, RR); all are local, touching at most three nodes.

Where it lives

Less common than red-black trees in production. AVL is read-optimal but write-heavy. Used in Windows NT's VirtualAlloc, some database engines, in-memory geometric searches.

The key insight

AVL trees are "more balanced" than red-black trees: better for read-heavy workloads. Red-black wins when writes dominate, because rebalances are cheaper.