Every programmer has hit it: you insert a key and it lands in the same slot as another. A collision. The usual fixes — chaining, open addressing — keep lookups fast on average, but the worst case can still drag to .
Perfect hashing sidesteps the problem entirely. If you know the complete set of keys in advance and that set never changes, you can build a hash table with zero collisions — every key maps to a unique slot, and every lookup takes exactly time, no matter what.
The scheme was made rigorous in 1984 by Michael Fredman, János Komlós, and Endre Szemerédi (the FKS scheme), who proved you can achieve this in space and construct the table in expected time. That result sits at a remarkable intersection: a data structure whose worst-case guarantee matches the theoretical lower bound for the problem.
Comments
Loading comments...