# Hash Collision

> Two keys that land in the same slot of a hash table.

**Field:** Software Development  
**Category:** Algorithms & Data Structures  
**Also known as:** Collision (Hashing), Hash Clash, Collision Resolution

## Think of it like

It is like two kids given the same coat hook. The school needs a plan, or one coat falls.

## Definition

A hash collision happens when two different keys get the same slot from a hash function. There are more possible keys than slots, so this always happens sooner or later. A hash table must handle it. One way is to keep a short list in each slot, called chaining. Another is to try the next free slot, called open addressing.

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

## Common mistake

Thinking a good hash function never collides. It always can; the table just has to cope.

## Three principles

- **Always possible.** More keys than slots.
- **Chaining.** Keep a list in the slot.
- **Open addressing.** Try the next free slot.

## Related terms

- [Hash Table](https://learn.benibix.com/term/development/hash-table)
- [Dictionary](https://learn.benibix.com/term/development/dictionary)
- [Time Complexity](https://learn.benibix.com/term/development/time-complexity)
- [Linked List](https://learn.benibix.com/term/development/linked-list)
- [Hashing (Cryptography)](https://learn.benibix.com/term/development/hashing)

![Two keys, cat and act, go into a hash function. Both come out as slot 3 of a table with six slots. Slot 3 holds a short chain: cat first, then act linked after it, so both values are kept.](https://learn.benibix.com/diagrams/dev7-hash-collision.svg)

---

Source: https://learn.benibix.com/term/development/hash-collision
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
