Cuckoo hashing explained in plain terms means understanding the table that evicts its own keys, a scheme from 2001 that stores every key in one of two places and kicks the occupant out when a newcomer arrives. The central question is why a table would move keys around instead of chaining them in place, and the answer is that moving keys keeps lookups to two probes at most, so cuckoo hashing gives programs a worst-case guarantee no chained table can offer, and that guarantee is the whole point of the design.
Cuckoo hashing is a hash table scheme created by Rasmus Pagh and Flemming Friche Rodler, presented at the European Symposium on Algorithms in 2001. It stores each key using two hash functions and two tables, and it is built on the idea that a key should have exactly two homes, which means the design is meant for lookups that must never be slow, and that focus is what makes it unlike the tables of its era.
This article sets out five facts that explain what cuckoo hashing is, how it works, and where it runs in the real world.
Key takeaways
- Cuckoo hashing is a table scheme from 2001, by Pagh and Rodler.
- Every key has exactly two possible places.
- Lookups take at most two probes, in the worst case.
- Insertions kick occupants to their other home.
- A loop means the table is rebuilt with new hashes.
What cuckoo hashing is
Cuckoo hashing is a table that stores each key in one of two slots, and that strictness is what makes it unusual among tables. A key hashes to one slot in each of two tables, which means a lookup checks at most two places, and because there is no chain to walk, the worst case is the same as the best case.
Its signature feature is the eviction. Most tables chain colliding keys in place, but cuckoo hashing kicks the occupant to its other home, which means an insertion can set off a chain of moves, and because each move lands in a fresh slot, the chain usually ends quickly.
The design was a reaction to the cost of worst cases. Chained tables are fast on average but slow when one bucket fills, so Pagh and Rodler asked how a table could promise constant lookups always, because a promise that holds only on average is no promise at all, and that practicality is what made cuckoo hashing worth publishing.
It became one of the best-known table schemes in the world, and it is named in every discussion of the field. Cuckoo hashing won the European Symposium on Algorithms test-of-time award in 2020, it is still the first example engineers meet when they learn that a table can guarantee its lookups, which means the design survives as a tool even though it is more than twenty years old.
Our guide to SplitMix64 explains the fast mixer often used to build cuckoo hash functions, and our guide to MurmurHash explains the earlier table hash it is measured against.
How cuckoo hashing works
Everything starts with the two hash functions, which give each key two homes. Cuckoo hashing hashes a key with h1 for the first table and h2 for the second, which means the homes are independent, and because the functions are chosen at random, the homes spread evenly.
Each lookup begins with two probes, which check both homes. Cuckoo hashing looks in the first table’s slot and then the second, which means a miss is decided in two steps, and because the probes are independent, they can even run in parallel.
The insertion is what makes the design work as a whole. Cuckoo hashing places a new key in its first home and kicks any occupant to its other home, which means the evicted key moves on, and because each kick lands somewhere new, the chain of moves usually ends at an empty slot.
The loop spreads the effect further. A chain of kicks can circle back on itself, which means the same keys keep evicting each other, and because a loop cannot end, the table detects it after a fixed number of kicks.
The rebuild is what turns a loop into a fresh start. Cuckoo hashing picks two new hash functions and rehashes every key, which means the loop is broken by new homes, and because rehashing is rare, its cost is spread thin across many insertions.
The result comes from the two probes, read out as found or not found. Cuckoo hashing answers every lookup in constant time, which means the answer is fast whatever the table, and that speed is exactly what a router or cache needs for its hot path.

Comparing cuckoo hashing with other table schemes
Cuckoo hashing is one of several table schemes built for fast lookups, and each was built with a different emphasis. Chaining is the classic scheme that links colliding keys in place, linear probing is the open-addressing scheme that walks to the next free slot, and cuckoo hashing is the one built on two homes for a worst-case promise, while each approach trades something for something else.
The table below sets out the main contrasts between the leading approaches.
| Aspect | Cuckoo hashing | Chaining | Linear probing |
|---|---|---|---|
| Lookup worst case | Two probes | Long chain | Long walk |
| Insertion | Kicks keys | Appends | Walks forward |
| Memory | Two tables | Linked lists | One table |
| Designed for | Guaranteed lookups | Simplicity | Cache speed |
| Best for | Routers and caches | General tables | Small tables |
The practical result is that cuckoo hashing is the right choice for guaranteed lookups, chaining suits general tables, and linear probing fits small tables instead.
Where cuckoo hashing is used
Routers use it for forwarding tables. A router that looks up a destination millions of times a second needs a lookup that never spikes, because a slow lookup drops packets, and that guarantee is the reason cuckoo hashing earns its keep in network hardware.
Caches use it for hot keys. A cache that serves the same keys again and again needs lookups that stay flat under load, because a chain that grows with traffic is a cache that slows down, and that flatness is the reason cuckoo hashing appears in cache designs.
Databases use it for in-memory indexes. An index that must answer point lookups in constant time chooses cuckoo hashing, because a worst-case promise beats a good average when a query must return now, and that promise is the reason it appears in storage engines.
Hardware uses it for exact matching. Chips that match keys at line rate build cuckoo tables in silicon, because two probes fit a pipeline, and that fit is the reason the scheme runs in real devices rather than only in papers.
Teaching uses it as the eviction example. Courses introduce cuckoo hashing when they explain that a table can move keys, because it is the clearest case of the idea in a real design, and a student who understands cuckoo hashing understands why worst cases matter.
Strengths and limits
The greatest strength of cuckoo hashing is its lookup promise. A table that answers every lookup in two probes gives routers and caches a guarantee no chained table can match, and that strength is real, measured in the award it won and confirmed by the hardware that uses it.
It is also a strength that the design is simple to explain. Two hash functions and two tables is a design anyone can describe, and that simplicity is worth more than cleverness in a field where a table nobody can reason about is a table nobody trusts.
The limits are real, though, and the biggest is the load ceiling. Cuckoo hashing slows down as the table fills, which means a table above about half full starts looping and rebuilding, and a system that must pack keys tight must use a different scheme instead.
Cuckoo hashing checklist
- Use cuckoo hashing for lookups that must never spike, never for packed tables.
- Remember every key has exactly two possible homes.
- Note a lookup checks at most two probes.
- Compare it with chaining to see two kinds of collision handling.
- Study the eviction, which is what keeps lookups constant.
- Check the load, since a half-full table starts looping.
- Keep the hash functions fresh after a rebuild.
- Read the Pagh and Rodler paper to see how the scheme was built.
- Choose chaining when the table must run nearly full.
Frequently asked questions
What is cuckoo hashing in simple terms?
It is a 2001 table scheme that gives every key two possible slots, kicks occupants out when a newcomer arrives, and guarantees lookups in at most two probes.
Who created cuckoo hashing?
Rasmus Pagh and Flemming Friche Rodler, who presented it at the European Symposium on Algorithms in 2001.
How is cuckoo hashing different from chaining?
Chaining links colliding keys together in one bucket, but cuckoo hashing moves the colliding key to its second home, so lookups never walk a chain.
Is cuckoo hashing still secure?
It is fast and well studied, but it is a table scheme, not a cryptographic hash, so it must never guard secrets or signatures.
Where is cuckoo hashing used?
In routers, in caches, in database indexes, in hardware matching, and in teaching about hash tables.
When should I use cuckoo hashing?
When lookups must be constant in the worst case, when the table stays under half full, or when you study table design.
The bottom line
Cuckoo hashing explained in one line is this: the table that kicks keys out, a 2001 design of two homes and eviction chains that promised constant lookups and taught the field that a worst case is worth designing for.
It is proof that moving keys beats chaining them, and the reason it still matters is that every table scheme designed since has been judged partly by the lesson cuckoo hashing taught.
This article is general information about how cuckoo hashing works, not advice about choosing encryption for a particular device or system.







