Hash tables are everywhere: behind dictionaries in Python, maps in Java, and the indices that make databases fast. The idea is simple — hash a key to a slot, read or write in one step. , constant time.
The problem is collisions. When two keys hash to the same slot something must give. Standard solutions — chaining with linked lists, or probing nearby slots — degrade to in the worst case or at least add unpredictability under heavy load.
In 2001, Rasmus Pagh and Flemming Friche Rodler published a scheme that trades that uncertainty away entirely. The idea was named cuckoo hashing after the bird that lays its egg in another bird's nest and ejects the existing occupant.
The rule is elegant: every key has two possible slots (one per hash function). Insertion tries the first slot. If it's taken, the resident is evicted to its own alternate slot — which may itself evict another occupant — and so on, in a chain. The result: lookup is always worst-case , because a key can only ever be in one of two fixed positions.
Comments
Loading comments...