The load factor α = n/m — entries over slots — governs everything. Chaining degrades slowly; open addressing’s cost blows up as α → 1 (like 1/(1−α)). So tables rehash when α crosses a threshold (often 0.75), doubling m. Here 7/8 = 0.875 trips the resize; after doubling to 16, α drops to 0.4375 — amortized O(1) restored.
The demo computes α, trips the resize at 0.875, and shows the new α after doubling: live demo
“Rehashing makes hash tables O(n) sometimes, so not O(1).” — the doubling cost is amortized away: each element is copied O(1) times on average. cited
One number decides speed. arithmetic
On i-13 (i-13’s / is real division), 7/8 trips the resize; doubling gives 7/16: