AlgoFrames

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