🧮Hash Collision
Also known as Collision (Hashing), Hash Clash, Collision Resolution
Two keys that land in the same slot of a hash table.
Think of it like
It is like two kids given the same coat hook. The school needs a plan, or one coat falls.
Example
The keys "cat" and "act" both hash to slot 3. The table keeps both in a little list at slot 3.
Why it matters
Too many collisions make a fast table slow. Good hash functions spread keys out so most slots hold one item.
Definition
Common mistake
Key takeaways
- 1Always possible. More keys than slots.
- 2Chaining. Keep a list in the slot.
- 3Open addressing. Try the next free slot.