II · Trees, with shape

Skip list

Probabilistic balance, beautifully.

The story

Pugh's paper is a masterpiece of plain language: "Skip Lists: A Probabilistic Alternative to Balanced Trees". Instead of complex rotations, every node flips a coin for how high to be. Tall nodes form an "express lane" past short ones. Average-case all-O(log n), worst-case O(n). But the worst case has probability 2^(−n).

How it works

A linked list with extra forward pointers at exponentially decreasing densities. Lookup walks the highest level until overshooting, drops down, repeats. Insert: flip coins to determine height, splice in at all relevant levels.

Where it lives

Redis sorted sets (ZSET). LevelDB and RocksDB's in-memory MemTable. Concurrent maps in Java's ConcurrentSkipListMap. Apache Cassandra.

The key insight

Lock-free skip lists are easier to write than lock-free balanced trees. That single property is why they appear inside high-concurrency systems where red-black trees would need a global lock.