In a hash table, what is a collision?

Two different keys hash to the same slot, so the table needs a plan for sharing.

Start playing free

  1. Two programs writing the same file
  2. Two different keys getting the same hash slot ✔
  3. 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.

The dad joke
Two keys hashed to the same slot. Now they are bucket buddies.
Like this card?
Play the game

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).

  1. 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.

Test yourself in the game