Zig / Zig-Zig / Zig-Zag

Three rotation cases: parent is root (zig, single rotation), same side (zig-zig, two same-direction rotations), opposite (zig-zag, alternating).

Advertisement

Splay after every op

Search: splay found node to root. Insert: splay new node. Delete: splay target, remove, splay predecessor.

Advertisement

Amortized analysis

Potential function based on node ranks. Each op's amortized cost = O(log N) even though individual ops can be O(N).

Locality wins

Recently accessed items near root. Great for skewed access patterns. Beats balanced trees in practice on 90/10 workloads.