On this page
A hash table turns each key into a slot number in an array, so a lookup should take one step. The catch is that two keys can land in the same slot. The Stanford CS161 hashing notes define the load factor as α = n/m, where n is the number of stored elements and m is the number of slots.
Why are hash table collisions inevitable?
A hash function squeezes a huge set of possible keys into m slots, so it cannot be one-to-one, and the Stanford CS161 notes call two keys landing in one slot a hash collision. The surprise is how early that starts.
The birthday problem shows that in a group of just 23 people, the probability that two share a birthday is 50.7%. Swap days for slots and you have a hash table: the same page gives p ≈ 1 − e^(−n(n−1)/(2d)) for n items in d bins, and lists hash collisions as an application.
Worked example: with m = 1,000,000 slots, setting p = 1/2 gives n ≈ √(2m ln 2) ≈ 1,178 keys, so a collision is a coin toss when the table is only about 0.12% full. Check it with linearity of expectation and indicator variables: each of the n(n−1)/2 pairs collides with probability 1/m, giving 1,178 × 1,177 / 2,000,000 ≈ 0.69 expected colliding pairs. Collisions are expected long before a table is full, so you design around them.
Chaining vs open addressing: what is the difference?
Wikipedia's hash table article names separate chaining and open addressing as the two common ways to resolve collisions.
Separate chaining: each slot holds a list of every key that hashed there, so α can exceed 1.
Open addressing: each slot holds at most one key. On a collision you follow a probe sequence until you find the key or an empty slot, so α must stay below 1.
Linear probing: the simplest probe sequence, trying the next slot each time. It is cache-friendly, but the CS161 notes warn that long runs of full slots build up, because an empty slot after i full ones is filled next with probability (i + 1)/m.
How does the load factor change the expected number of probes?
Under simple uniform hashing, the Stanford CS161 notes, which copy parts from the CLRS textbook, derive these averages:
Chaining, successful search: 1 + α/2 − α/(2n) elements examined, which is about 1 + α/2.
Chaining, unsuccessful search: one list of expected length α.
Open addressing with ideal uniform hashing, unsuccessful search: at most 1/(1 − α) probes, which is 2 when the table is half full and 10 when it is 90% full.
Linear probing does worse than that ideal because of clustering. Sedgewick and Wayne's Algorithms gives about ½(1 + 1/(1 − α)) probes for a search hit and ½(1 + 1/(1 − α)²) for a search miss or insert, so misses grow like 1/(1 − α)².
Worked table: probes at four load factors from those formulas (a hit finds the key; the ideal miss is an upper bound):
α = 0.25: chaining hit 1.13; ideal miss 1.33; linear probing hit 1.17, miss 1.39.
α = 0.5: chaining hit 1.25; ideal miss 2; linear probing hit 1.5, miss 2.5.
α = 0.75: chaining hit 1.38; ideal miss 4; linear probing hit 2.5, miss 8.5.
α = 0.9: chaining hit 1.45; ideal miss 10; linear probing hit 5.5, miss 50.5.
Going from half full to 90% full makes a linear-probing miss about twenty times as costly (2.5 to 50.5 probes), while a chaining hit barely moves (1.25 to 1.45).
When should you resize a hash table?
Resize when α reaches a chosen maximum, then rehash every key into the bigger array, because slot numbers depend on m.
Java's HashMap documentation uses a default load factor of 0.75 and, once entries exceed load factor × capacity, rehashes to about twice the number of buckets.
Wikipedia's hash table article says acceptable maximum load factors for open addressing range around 0.6 to 0.75, and that the best maximum for separate chaining is typically between 1 and 3.
For linear probing, Wikipedia's linear probing article describes a common choice: double the table when α would exceed 1/2, which keeps it between 1/4 and 1/2.
Doubling spreads each expensive rehash over the many cheap inserts before it; the post on Big O notation and growth rates shows how to compare costs like these.
A checklist for your own table:
Choose chaining if you delete often or cannot bound n; choose open addressing if memory locality matters most.
Pick your maximum α from the worst miss cost you can accept, using the worked table.
Grow by doubling and rehash every key.
Test with real keys: a weak hash function breaks the uniform assumption long before α does.
If load factor or expectation still feels slippery, the Fermi Concept Library has a lesson for every concept in mathematics and computing, and the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer.



