Intuition The one core idea
A hash function is a rule that turns any key into a small box number so you can stash a thing in a box and later walk straight back to that same box to fetch it. Everything else on the parent page — determinism, uniformity, speed, load factor — is just a demand we make on that rule so the "walk straight back" stays fast and reliable.
This page assumes you have seen nothing . Before you read the parent note , you need every symbol it throws at you. We build them one at a time, each on top of the last.
Picture a wall of numbered mailboxes. You get a letter with a name on it. You need a rule that reads the name and points at exactly one box. That rule is the hash function. Hold this picture — every symbol below is a label on some part of it.
A key is the thing you want to store or find — a name, a word, a number, an ID. It is the input to the rule.
Picture: the name written on the front of the letter.
Why the topic needs it: hashing is about finding things by their key without searching everything. No key, nothing to look up.
The parent writes { 0 , 1 , … , m − 1 } and j ∈ { 0 , … , m − 1 } . These are just two pieces of shorthand.
{ } = "the collection of"
{ 0 , 1 , 2 , 3 } means "the collection containing 0, 1, 2 and 3". The three dots … mean "keep counting the same way".
So { 0 , 1 , … , m − 1 } = "all the whole numbers starting at 0 and stopping just before m ".
∈ = "is one of"
j ∈ { 0 , … , m − 1 } reads out loud as "j is one of the box numbers". It is a membership check, nothing more.
Picture: { 0 , … , m − 1 } is the list of box numbers written under each mailbox . ∈ points at one of them.
{ 0 , … , m − 1 } as "0 to m"
Why it feels right: you counted to m .
The fix: there are exactly m boxes, and computers count from 0, so the last box number is m − 1 , not m . Box m does not exist.
U — the universe of keys
U is the collection of every key that could ever possibly appear — every string, every 64-bit number. Usually gigantic.
Picture: m is the handful of boxes on the wall. U is the whole city of every possible name that could ever be mailed.
∣ U ∣ = "how many things in it"
∣ U ∣ means "the size of U " — count its members. So ∣ U ∣ ≫ m (read: "∣ U ∣ is much much bigger than m ", the ≫ is "hugely greater than") says: way more possible keys than boxes.
Why the topic needs it: because there are more keys than boxes, two keys must eventually share a box. That forced sharing has a name — the Pigeonhole Principle — and the whole idea of collision resolution exists only because of it.
This one line is the heart of the parent note. Let's earn every piece.
Definition Function arrow notation
h : A → B
h is the name of the rule .
A (here U ) is what you are allowed to put in — the inputs.
B (here { 0 , … , m − 1 } ) is what can come out — the box numbers.
The arrow → reads "maps to ": "h takes any key from U and hands back a box number".
Picture: an arrow leaving a name in the city and landing on exactly one box on the wall.
h ( k ) — the rule applied to key k
h ( k ) means "run the rule h on the key k " and the result is the box number. If h ( "cat" ) = 7 , the letter "cat" goes in box 7.
Why the topic needs it: every property in the parent — deterministic, uniform, fast — is a sentence about h . You cannot read those sentences until h ( k ) means something concrete.
⟹ = "forces" / "therefore"
P ⟹ Q reads "if P is true, then Q must be true".
So k 1 = k 2 ⟹ h ( k 1 ) = h ( k 2 ) reads: "if two keys are the actual same key, the rule must give them the same box." That is determinism — the plainest possible demand: don't change your mind.
Picture: feed the same name in twice → the arrow lands on the same box both times.
The parent writes P ( h ( k ) = j ) = m 1 . Two ideas hide here.
P ( something ) — chance, as a number between 0 and 1
P ( E ) is "how likely E is". P = 0 means never, P = 1 means always, P = 2 1 means half the time.
m 1 is exactly "perfectly fair"
If there are m boxes and a key is equally likely to land in any one, then each box gets an equal slice of the whole. The whole is 1, cut into m equal slices → each slice is m 1 . That is what "uniform" means: every box, same fair share.
Picture: a pie sliced into m identical wedges. See Modular Arithmetic for how real rules chop keys into those wedges.
n — how many keys you actually stored
Not how many could exist (∣ U ∣ ), but how many letters you have really put in the boxes so far.
α (Greek "alpha") — the load factor
α = m n = boxes available letters stored
It answers: "on average, how full is each box?"
Picture: n = 8 letters shared over m = 4 boxes → each box holds about 8/4 = 2 letters. That "2" is α .
Intuition Why this single number controls speed
If each box holds α letters on average, then finding a letter means: compute the box (one step), then flip through the little pile inside (α steps). So work ≈ 1 + α . Keep α small and constant → work stays constant → the famous fast hash table. When α grows too big you must add boxes — that is Load Factor and Rehashing .
The parent derives chain length with ∑ and E . Both are just "add things up".
∑ i = 1 n x i — "add up the x 's"
The big Greek S (Σ , "sigma") says sum . ∑ i = 1 n x i means "let i run from 1 to n , and total up every x i ." Example: ∑ i = 1 3 i = 1 + 2 + 3 = 6 .
E [ X ] — expected (average) value
E [ X ] is the average outcome you'd get if you repeated the experiment forever. If each of n keys has a m 1 chance of landing in one box, the average count in that box is n ⋅ m 1 = m n = α . That is the parent's chain-length result, and it needs nothing but "add up m 1 , n times."
Picture: n coin-flips, each with a small chance of "lands here"; the pile you expect to see is their total chance.
Every real hash rule ends in this.
k mod m — the remainder after dividing k by m
Divide k by m and keep only what's left over . 50 mod 7 : 7 × 7 = 49 , remainder 1 , so 50 mod 7 = 1 .
Intuition Why mod is the natural box-picker
Whatever huge number the key becomes, mod m folds it back into the range 0 to m − 1 — exactly the box numbers . It is a wrap-around: like a clock, count past m and you're back at 0. Full machinery lives in Modular Arithmetic .
Picture: a number line wrapped around a circle of m marks; wherever k lands on the circle is its box.
p i — p multiplied by itself i times
p 0 = 1 , p 1 = p , p 2 = p ⋅ p , and so on. These are position weights : character 0 gets weight p 0 , character 1 gets weight p 1 …
Intuition Why weights, not a plain sum
If you just added letter values, "abc" and "cab" would tie — same letters, same total. Multiplying each letter by a different p i gives every position its own loudness, so word order changes the result. That is the whole reason the polynomial string hash beats "sum the ASCII".
Picture: the same three letters shuffled — plain sum keeps one flat pile; weighted sum stacks them at different heights, so shuffles look different.
Function h maps key to box
Universe U vs table size m
Pigeonhole - collisions forced
Deterministic - same key same box
Probability and one-over-m
Summation and expected value
Modular arithmetic - mod m
Position weights p to the i
Hash function properties DUF
Cover the right side and answer aloud. If any stalls, reread that section.
The symbol ∈ means "is one of / is a member of".
{ 0 , 1 , … , m − 1 } lists which thingsthe m box numbers, from 0 up to m − 1 (there are m of them).
In h : U → { 0 , … , m − 1 } , what is U the universe — every key that could ever possibly appear.
Why is ∣ U ∣ ≫ m important far more possible keys than boxes, so collisions are forced (pigeonhole).
h ( k ) evaluates tothe box number the rule assigns to key k .
k 1 = k 2 ⟹ h ( k 1 ) = h ( k 2 ) states which propertydeterministic — same key always lands in the same box.
P ( h ( k ) = j ) = m 1 meansevery box is equally likely — a perfectly uniform (fair) rule.
The load factor α = m n measures average fullness — expected number of keys per box.
∑ i = 1 n m 1 equalsm n = α (add m 1 to itself n times).
50 mod 7 equals1 (remainder after dividing 50 by 7).
Why use weights p i in a string hash so letter order matters — "abc" and "cab" get different hashes.