Hash Table Insert
Hash the key to a slot, then walk forward past anything already there.
Decision · step 3 of 8Hash Table: Insert that walks past a collision
Slot 1 holds 12, not 45. Walk on to slot 2.
What you will see
KEY -> HASH -> INDEX; the key travels to its bucket; a collision triggers chaining or probing.
Cost
| Best | O(1) |
|---|---|
| Average | O(1) |
| Worst | O(n) |
| Space | O(1) |
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.
Before this
Taught by the same lesson
Hash Table covers these too, in the same run.