Robin Hood Hashing: Why a Longer Probe Can Win the Slot
2026-11-10

Robin Hood Hashing: Why a Longer Probe Can Win the Slot

Robin Hood Hashing changes which key gets to stay in a slot when two keys compete for it. In a linear probing table, each key has a home slot and proceeds through adjacent slots when necessary. At an occupied slot, the insertion compares how far the arriving key has traveled with how far the resident traveled to reach that same slot. A key that has traveled farther can take the slot, sending the resident onward. The same distance rule helps a later lookup decide when it has gone far enough.

Each distance starts at the key's own home slot

The hash-to-slot mapping determines a key's home. A key at its home has distance zero; one that has moved to the immediately following slot has distance one. Two keys compared at slot four might therefore have different distances. If one belongs at slot two and the other belongs at slot four, their distances at the comparison point are two and zero.

That count is different from the absolute slot index. In a circular table it follows the direction of probing through the wrap. A key with home at the last slot that lands in the first slot has taken one step. Recording the distance convention matters because the comparison only works when the query and resident refer to the same direction and units.

A displaced key continues the insertion

Consider an illustrative run of slots two through five. Initially A occupies its home at two, B occupies its home at three, C occupies its home at four and slot five is empty. New key X has home slot two. At two, the resident and X both have distance zero, so the illustrated strict comparison leaves A in place. At three, X is one step from home, and B is at home. X takes slot three and B becomes the key being placed.

B moves to four, one step from its own home at three. The resident C is at its own home, so B takes the slot. C then moves to the empty slot five, one step from its home. The final occupants are A, X, B and C. Kelly, Pearlmutter and Maguire describe this style of displacement and continuation in the background section of their original concurrent hashing paper.

Initial A, B, C, empty become A, X, B, C. A remains at distance zero and the other keys are each one step from home.
X wins slot three and the displaced keys continue through the next slots. Source: Zhilianhai editorial desk, original AI-assisted conceptual illustration.

Simply continuing with X until the empty slot would give X a distance of three while the three existing keys remained at distance zero. Displacement spreads that distance among the participants. The illustrated insertion adds one key while preserving every resident key and its associated value. It can write more slots than an insertion that leaves all residents in place.

A shorter resident can end a search

Now search for an absent key Z whose home is also two. At slots two and three the resident distances match the distance of the search. Matching distances alone do not establish key equality, so the lookup checks the keys and continues. At four the search has distance two while resident B has distance one. If Z had reached that point during a valid insertion, its greater distance would have displaced B. The arrangement therefore rules out Z further along this probe sequence.

The comparison is about a particular key at a particular slot. It does not require all stored distances to rise across a cluster. A short resident can occur after a long one because the keys have different homes. Paul Khuong's experimental write-up gives a linear probing implementation that uses ordered hash information to support the corresponding early stop.

Probe Z grows from zero to two. Resident B at slot four has distance one, so the search stops there.
The query reaches the first resident with a strictly shorter probe distance at slot four. Source: Zhilianhai editorial desk, original AI-assisted conceptual illustration.

Deletion has to preserve what a search can infer

A newly created empty hole can make a search stop before reaching a displaced resident. For example, if X vanished from slot three and a lookup for B started at three, treating that hole as the end would hide B at four. One deletion strategy discussed by Kelly and colleagues shifts subsequent displaced keys backward, until an empty slot or a key already at home is encountered. A shift reduces the moved key's distance by one.

The specific insertion and deletion rules belong together. An implementation can preserve a different deletion marker with its own lookup rules. The example describes an ordinary sequential state. If readers and writers operate together, the implementation has to control the consistency of the slots visible to a search while keys are being moved.

Keep the distance and the storage policy together

A design description can name the home mapping, probe order, tie behavior, stopping rule and deletion treatment. These details explain how a table stores and retrieves exact keys. They also show what to test when changing capacity or replacing the mapping, because that changes the home positions on which the distance comparison depends.

Primary references are the Concurrent Robin Hood Hashing paper and Paul Khuong's linear probing experiments and implementation. See the industrial data collection and technical article directory.

18028484626 CONTACT US

公司:智联海(惠州)科技有限公司

地址:惠州仲恺高新区陈江街道白云山工业大道 5 号六楼 601

Q Q:18028484626

Copyright © 2002-2026

粤xxx

咨询 在线留言 电话:18028484626
微信 微信扫码添加我