← All Tools

Skip List Visualizer

A skip list keeps a sorted linked list and a stack of sparser express lanes on top. Each inserted key climbs one extra level for every heads flip, so about half the keys have height 1, a quarter have height 2, an eighth have height 3, and so on โ€” giving expected O(log n) search that beats a plain linked list without needing the rotations of a balanced tree. Redis, LevelDB's MemTable, and Java's ConcurrentSkipListMap all ship one.

0.50 โ€” set before inserting; existing tower heights aren't retroactively resampled.

Skip list stats

Keys stored0
Max level0
Node pointers0
Total forward links0
Last op cost (hops)โ€”
Expected log_{1/p} nโ€”

Tower height distribution

Yellow tick = geometric expectation n ยท p^(h-1) ยท (1 โˆ’ p).

Trace

visited on search path   match   just inserted

Why skip lists?

A sorted linked list gives O(n) search โ€” no way to binary-chop into pointer chases. A skip list bolts on express lanes: level 1 is the base list, level 2 links roughly every second node, level 3 every fourth, and so on. On lookup you start at the top-left header and repeatedly step right while the next key stays โ‰ค target, dropping down whenever the next key overshoots. Because each node's height is a fresh Geometric(1 โˆ’ p) draw with p usually 1/2, the expected number of hops is log_{1/p} n โ€” the same asymptotic as a balanced tree but with no rotations, no colour bits, no rebalancing math. Redis' sorted sets and ZooKeeper's snapshot index both use skip lists because concurrent writers get much simpler lock-free updates than a red-black tree can offer.