AlgoScope

Rehashing

AlgorithmintermediateHash Tables and Collision Handlingalso called resize

When the load factor exceeds a threshold, double the buckets and reinsert every key.

Decision · step 2 of 12Rehashing: One rehash
0112234probe

insert 12. 12 mod 5 = 2 and slot 2 is free. Load 1 / 5 = 0.20, under 0.70.

Open in the player →or start at step 2

What you will see

A new, larger table appears; keys migrate one by one to their new buckets.

How rehashing works →

Cost

BestO(n)
AverageO(n)
WorstO(n)
SpaceO(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.

Taught by the same lesson

Rehashing covers these too, in the same run.