Explain like I'm five · Systems

What is a Hash Algorithm?

Hash algorithms, told as a story about computing a number to point straight at the right slot in the toolbox.

need wrench #14 among fifty toolssearching one by one might mean checking the whole box

With so many tools, finding one takes forever.Searching one by one might mean checking the whole box.

327814413? 27? 8? nope, next...with no order, every search starts from scratcha rule to point straight at the right slot would help

Searching from scratch every time is too slow.A rule to point straight at the right slot would help.

012341414 mod 5 = 4hash algorithm: compute a number, point straight at the slotone calculation tells you the slot — no searching

A hash algorithm computes a number to point straight at the slot.One calculation tells you the slot — no searching.

Compute with a hash functioncomputes the tool's number by a fixed rule
Point straight at a slotthe result is the slot number itself
Occasional collisionstwo tools can point to the same slot
Chain them when collidedhangs several items in one slot
012347227 mod 5 = 2, 22 mod 5 = 2 — same slot!handling the collisionchaining — hang them one after another in the slotopen addressing — slide into the next empty slot

Two tools can point to the same slot — a collision.Chain the colliding tools in one slot, or slide one into the next empty slot.

0123with enough slots, one calculation nearly always sufficesa full box means more collisions and more searchingfast lookup means keeping more slots than tools

A full toolbox slows tool lookup back down.Fast lookup means keeping more slots than tools.

In one breath

A hash algorithm computes a number from the data to point straight at a storage slot (bucket), so lookup and storage take roughly one calculation.

A hash algorithm feeds a key into a hash function to produce an array index (bucket number). A hash table built on this achieves near-O(1) average search and insertion, far faster than scanning everything with linear search (O(n)). When different keys hash to the same bucket — a collision — it's resolved by chaining (linking multiple items in one slot) or open addressing (sliding into the next free slot). As the load factor rises (too much data for too few buckets), collisions increase and performance drops. This is the data-structure/algorithm sense of 'hash', distinct from cryptographic hash functions used to verify message integrity.

When grown-ups say it

Hash Function
The rule that computes the number. Always gives the same slot for the same input.
Hash Table
The toolbox with tools sorted into slots. Average O(1) for lookup and insertion.
Bucket (Slot)
The slot the computed number points to. The hash value becomes the slot number.
Collision
Different tools pointing to the same slot. Resolved with chaining or open addressing.
Chaining
Hanging multiple items one after another in the slot. Links the colliding items in a list.
Open Addressing
Sliding into the next empty slot. Gets harder to find an empty slot as the table fills up.
Load Factor
The ratio of tools stored to the number of slots. Too high, and collisions rise.
Linear Search
Checking items one by one from the start. Much slower than a hash table — O(n).
Next story
New Warehouses That Swap in Place, No Erasing Needed →
Want another term as a picture book? Request →