Question DSA-HASH-0012
MediumWhy should hash tables usually have a prime number of slots when using h(k) = k mod m?
- A.
It reduces memory use
- B.
It prevents all collisions
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Hashing question
Why should hash tables usually have a prime number of slots when using h(k) = k mod m?
It reduces memory use
It prevents all collisions
Sign up free to see the answer and a step-by-step explanation.
It spreads keys with common patterns (such as multiples of 10) more evenly
Prime numbers are faster to divide by