Computer Science
5 things
4 Things a Good Hash Function Must Do
4 things about hash functions every CS student must know…
Quick check · tap an answer to continue
Lesson notes
Key points
- Deterministic: The same key must always produce the same hash, or lookups fail.
- Uniform spread: Keys should scatter evenly across buckets so no single chain grows long.
- Fast to compute: A slow hash ruins O(1), since every operation computes it first.
- Prime-sized tables help: With modulo hashing, a prime table size reduces patterns that cluster keys.
Takeaway: Good hashes are deterministic, uniform and fast.
Quick check: Why must a hash function return the same value for the same key?
- To save memory
- So lookups find the key
- To avoid rehashing
Lookup recomputes the hash; a different value points to the wrong bucket.
Lessons like this, for your syllabus.
Short narrated study videos written for your course, level and exam. Free to start.
Get lessons for your own syllabus