Implement and analyse hash tables
8 steps · about 4 h 35 min · Intermediate
- Model the hash-table operations (guide, Wikipedia, 35 min)
Relate keys, buckets, hashes and equality to lookup, insertion and deletion.
- Choose a hash function contract (guide, Wikipedia, 30 min)
Require stable equal-key hashes and useful distribution without confusing hashing with encryption.
- Implement separate chaining (guide, Wikipedia, 40 min)
Resolve collisions with per-bucket collections and measure how chain length changes.
- Implement open addressing (guide, Wikipedia, 40 min)
Explore probe sequences, empty markers and deletion without auxiliary chains.
- Track load factor (guide, Wikipedia, 30 min)
Connect occupancy to collision frequency, probe length and memory cost.
- Analyse resizing cost (guide, Wikipedia, 35 min)
Explain why occasional full rehashes can still yield bounded average insertion cost.
- Test adversarial collisions (guide, Wikipedia, 30 min)
See how poor or hostile key distributions can collapse expected constant-time behaviour.
- Compare with an ordered map (guide, Wikipedia, 35 min)
Choose between expected constant lookup and ordered worst-case logarithmic operations for the real workload.