Why it matters

Perfect hashing gives O(1) guarantees vs expected. Foundation for static-set fast lookup.

Advertisement

The architecture

Level 1: hash into buckets.

Level 2: per-bucket perfect hash (quadratic space).

Total O(n) space.

FKS perfect hashingLevel 1n bucketsLevel 2quadratic per bucketO(n) totalworst-case O(1)Minimal perfect hashing further compresses to bare n slots
Perfect hashing.
Advertisement

How it works end to end

FKS 1984: two-level.

Expected O(n) construction.

Minimal perfect hashing: exactly n slots.

Rebuild for dynamic sets.