Definition · The modeln keys are thrown into m slots, each key landing in a uniformly random slot, independently of the others. This is the idealisation a hash function is assumed to realise; Universal Hashing is where the assumption is replaced by something provable. A collision is a pair of keys in the same slot, and the load of a slot is how many keys it holds.
Theorem · The expected number of colliding pairsThe expected number of unordered pairs of keys that land in the same slot is n(n − 1)/2m, exactly, for every n and m.
Index the C(n, 2) = n(n − 1)/2 unordered pairs. For a pair {i, j} let Xᵢⱼ = 1 if keys i and j land in the same slot and 0 otherwise. The number of colliding pairs is X = Σ Xᵢⱼ.
Condition on where key i lands. Key j lands there with probability 1/m whatever that slot was, so P(Xᵢⱼ = 1) = 1/m and E[Xᵢⱼ] = 1/m.
Linearity of expectation gives E[X] = Σ E[Xᵢⱼ] = C(n, 2)·(1/m), which is n(n − 1)/2m. The indicators are dependent — collision is transitive — and linearity holds for dependent summands, so nothing here needs repair.
□
At 23 keys in 365 slots that is 253/365 ≈ 0.693, a number below one. The seeded throw on the panel produced exactly one colliding pair. Change the seed and the count moves between 0 and 3; the expectation does not move at all, and it is printed as the fraction 253/365 rather than as a decimal for the same reason every other exact quantity on this course is.
Theorem · The expected number of empty slotsThe expected number of slots holding no key is m(1 − 1/m)ⁿ, exactly.
For slot j let Yⱼ = 1 if slot j is empty. A single key misses slot j with probability 1 − 1/m, and the n keys are independent of each other, so all n miss it with probability (1 − 1/m)ⁿ.
So E[Yⱼ] = (1 − 1/m)ⁿ, and the expected number of empty slots is Σⱼ E[Yⱼ] = m(1 − 1/m)ⁿ by linearity. The Yⱼ are dependent — if m − 1 slots are empty the last one is not — and again that costs nothing.
□
Note which independence was used and which was not. Inside a single Yⱼ the n keys are independent, and that is a genuine hypothesis of the model. Between the Yⱼ nothing is assumed, and nothing is true. Keeping those two apart is the whole skill: the first is about the throws, the second would be about the slots, and only the first is available.
The birthday bound, multiplied out rather than estimated
The probability that all n keys land in distinct slots is the product (m/m)·((m − 1)/m)·…·((m − n + 1)/m), and the lab evaluates it as an exact fraction over BigInt. At m = 365 it first drops below a half at n = 23, where it is 0.492703…; so 23 keys make a collision more likely than not, and 22 do not. The familiar √(2m ln 2) ≈ 22.5 is a rule of thumb, and the panel does not use it — it searches upward through the exact product and reports the first n that crosses.
Example · Where collisions start, at three table sizesm = 64 slots: even odds at n = 10. m = 128: at n = 14. m = 365: at n = 23. m = 1000: at n = 38. Each of those is close to √m and nowhere near m. A table with a thousand slots is not comfortable until far fewer than a thousand keys have arrived — it sees its first collision at around forty, which is four per cent full.
This is why hash tables are engineered around load factors and chains rather than around avoiding collisions. Collisions are not an anomaly to be designed out; they are the expected state of a table that is a few per cent full, and Hashing with Chaining spends its whole page on what to do about them.
The maximum load, and what this library will not claim
Throw n keys into n slots. The mean load is exactly 1. The maximum load is Θ(log n / log log n) with high probability, and if each key picks two slots and takes the emptier the maximum drops to about ln ln n. Both of those are quoted on the panel and both are labelled STATED, NOT PROVED. Their proofs need Chernoff bounds, which no Subject in this library teaches, and stating a result is not proving it.
So the panel does the one honest thing available: it prints the stated figure and the counted maximum in adjacent rows. At m = 365 with 365 keys the stated one-choice figure reads 3.32 and the seeded throw's tallest slot held 4. Those do not contradict each other — an asymptotic growth rate with suppressed constants is not a prediction of a small instance — and the gap is a reminder of what a growth rate is and is not.
Partitioning and Load Balancing, on the System Design path, is where the maximum load matters rather than the mean, because a shard's capacity is set by its busiest moment. That course measures the same two quantities on real placements and quotes the same two asymptotics under the same caveat. Between the two pages the expectations are derived once, here, and the maximum is measured twice and derived nowhere.