workshop private

← all creations

Probe

viz · created 2026-09-09

One key stream into three open-addressing tables — linear probing, double hashing, Robin Hood — with every slot drawn as a bar of its displacement, so linear probing's clusters climb as staircases and Robin Hood flattens the same total into a hedge.

algorithmsinterview-prepcanvas

Three hash tables, one key stream, one hash function. Each table gets the same keys in the same order and differs only in where it puts them when the slot it wanted was taken. Every slot is drawn as a bar whose height is that key’s displacement — how far past its home slot it ended up — so a panel is a skyline of what lookups will cost.

Drag the load factor and the three skylines stop resembling each other:

And here is the thing the picture is built to show. Robin Hood does not make the table faster on average. It cannot. At 90% load both linear panels report a mean of 6.60 probes and a total displacement of 644 — not close, identical, at every load factor and every seed. What changes is the shape: linear probing’s worst key costs 68 probes and Robin Hood’s costs 15. The bars are a redistribution, not a reduction.

Why the total can’t move

Cut the ring at any empty slot (open addressing always leaves one). Now look at a single cluster — a maximal run of occupied slots. Every key in that run is homed inside the run and sits at or after its home, so:

total displacement  =  Σ (slot it occupies)  −  Σ (slot it hashes to)

The second sum is fixed by the keys. The first is fixed too, because linear probing fills the same set of slots regardless of which key ends up in which — it never leaves a hole, so the occupied set depends only on the multiset of home positions. Both sums are settled before any policy gets a vote, and the total is their difference.

So a placement policy over a linear probe sequence has exactly one degree of freedom: who pays. First-come-first-served hands the whole bill to whoever arrives last, which is how you get a 68-probe key. Robin Hood spreads it evenly, which is why the panel is a hedge instead of a skyline. Averages are conserved; tails are a choice. (Verified rather than asserted: 1,000 random tables across five load factors, zero disagreements.)

Hover any bar to follow one key through all three tables at once — its home slot, where each policy put it, and what each lookup costs. It is worth finding a key that Robin Hood made worse: the flat tail is paid for by the keys that would otherwise have landed cheaply.

The column nobody looks at

miss is the mean probes for a key that isn’t in the table — the cost of every failed lookup, every “is this already here” check, every insert. It is the number that actually falls off a cliff. At 90% load linear probing needs 31.75 probes to conclude a key is absent, against Robin Hood’s 7.08 for the same keys in the same slots. Robin Hood gets to give up early: if the resident is closer to home than the searcher has walked, the searcher would have evicted it on the way in, so it cannot be further down the run. That early exit is free and it is most of the win.

Reuse

src/probe.js is a framework-free ES module — no DOM, no timers, no rendering:

Gotchas