Why mod table size
Warm-up · Multiple choice · about 2 min
A hash function can return any whole number, such as 98262 for "cat". A table with m buckets then computes hash(key) mod m. Why mod m?
Learn the idea first: Hash functions: from key to bucket index, a visual lesson.
More Hash functions: from key to bucket index problems
- Bucket for keys Warm-up
- Predict an anagram's bucket Standard
- Bucket index of every key Standard
- Bucket histogram Standard
- Implement a polynomial string hash Challenge