A hash collision happens when two different keys land in the same bucket. It happens because a hash function squeezes a huge space of possible keys into a small, finite number of buckets.
There are far more possible keys than slots, so by the pigeonhole principle some keys must share a slot. Even a great hash function cannot avoid this. It can only make collisions rare and evenly spread. Poor functions make it worse by clustering keys together.
Collisions are normal, not a bug, so every hash table has a plan for them. Common approaches store the clashing entries in a small list per bucket, or probe for the next open slot. Handling them well is what keeps lookups near O(1) instead of degrading.
Rewriting in plainer words…
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
A hash collision is when two different keys end up in the same bucket of a hash table.
It happens because the hash function maps a huge space of possible keys onto a small, fixed number of buckets.
There are far more possible keys than slots, so by the pigeonhole principle some keys have to share one.
Even a great hash function can't avoid that, but it keeps collisions rare and evenly spread, while a poor one clusters keys together.
So collisions are normal, and every hash table plans for them, either with a small list per bucket or by probing for the next open slot.
How well the table handles them decides whether lookups stay near O(1) or degrade as buckets fill up.
Weak answers to avoid
Treats collisions as a bug to eliminateWith more possible keys than slots, no hash function for arbitrary keys can avoid them. Say they are normal and that every table has a plan for them.
Says what a collision is, never whyThe question asks why. Name the squeeze from a huge key space into a few buckets and the pigeonhole principle, not just two keys sharing a slot.
Confuses a collision with a duplicate keyInserting the same key twice updates one entry. A collision is two different keys sharing a bucket, and the table must keep both.
Stops at the definition, no handling or costMention per-bucket lists or probing for the next open slot, and that handling collisions well is what keeps lookups near O(1).
Interview lens
Likely follow-ups, what you can say, and the weak answers to avoid.