What is the load factor α of a hash table, and how does it determine performance?
α = n / N, the number of entries per cell. The expected cost of an operation depends on α, not on n: with open addressing and evenly spread keys, an insert takes about $1/(1-α)$ probes.
* Up to about α = 0.5 inserts cost one or two probes; close to a full table they explode. *
The formula $1/(1-α)$ comes from the chance that a probe hits an occupied cell, which is about α. Then the expected number of probes is $1 + α + α^2 + … = 1/(1-α)$.
| α | 0.25 | 0.5 | 0.75 | 0.9 | 0.99 |
|---|---|---|---|---|---|
| probes ≈ 1/(1−α) | 1.3 | 2 | 4 | 10 | 100 |
The lesson: the cost depends on how full the table is, not how big it is. A table with a billion entries at α = 0.5 is as fast as one with ten entries at α = 0.5. That is why hash tables count as $O(1)$: the implementation keeps α bounded by growing the table (rehashing).
The worst case is still $O(n)$: if every key collides, everything ends up in one chain or one long probe run. A good hash function makes this very unlikely, but it is never impossible.
With separate chaining α may exceed 1 (chains just get longer); with open addressing α ≤ 1 always, and above about 0.7 it becomes slow.
Go deeper:
Hash table: load factor — typical thresholds for chaining and open addressing, and when to resize.