In a hash table, what is a collision?
Two different keys hash to the same slot, so the table needs a plan for sharing.
- Two programs writing the same file
- Two different keys getting the same hash slot ✔
- A key that is too long to hash
Why: There are far more possible keys than slots, so some different keys must land on the same slot. Tables handle it by chaining (a small list per slot) or open addressing (trying another slot).
Huh, didn't know that: Collisions are guaranteed by the pigeonhole principle: put more pigeons than holes and some hole gets two.
Two keys hashed to the same slot. Now they are bucket buddies.
References
Answer: Two different keys getting the same hash slot. There are far more possible keys than slots, so some different keys must land on the same slot. Tables handle it by chaining (a small list per slot) or open addressing (trying another slot).
- MIT 6.006 Introduction to Algorithms, Lecture 4: Hashing ocw.mit.edu/courses/6-006-introduction-to-algorithms-spring-2020/resources/mit6_006s20_lec4
Always exists keys a, b such that h(a) = h(b) → Collision!
Checked 2026-10-10.
Think this answer is wrong? Tap "Challenge this answer" on the card in the game and tell us why.
More stuff everyone should know
That's stuff everyone should know.