Rehashing
When the load factor exceeds a threshold, double the buckets and reinsert every key.
Decision · step 2 of 12Rehashing: One rehash
insert 12. 12 mod 5 = 2 and slot 2 is free. Load 1 / 5 = 0.20, under 0.70.
What you will see
A new, larger table appears; keys migrate one by one to their new buckets.
Cost
| Best | O(n) |
|---|---|
| Average | O(n) |
| Worst | O(n) |
| Space | O(n) |
Amortized O(1) per insert.
How you work with it here
play it through, step one change at a time, scrub to any step, run it on your own input, try operations in any order.
Screen readers: Buckets announce index, occupancy and keys; each step announces the hash value and where the key lands.
Reduced motion: Keys appear in their bucket with a crossfade instead of travelling from the hash label.