Follow the probes
Warm-up · Trace the algorithm · about 5 min
A table has 8 slots, uses key mod 8 and linear probing. Insert 3, 11, 5, 19 in this order and answer each question before the step plays.
Example 1
Input:
{"size":8,"keys":[3,11,5,19]}
Output:
[-1,-1,-1,3,11,5,19,-1]
Constraints
- 8 slots, hash = key mod 8
- A taken slot sends the key to the next slot
Learn the idea first: Open addressing: linear, quadratic probing, double hashing, a visual lesson.
More Open addressing: linear, quadratic probing, double hashing problems
- Clustering Standard
- Predict a double-hashing slot Standard
- Fill a table with linear probing Standard
- Implement insert with tombstones Standard
- Implement quadratic probing with resize Challenge