Also called Double hashing and Open addressing with a second hash.
fresh numbers
The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from hash table with double hashing's own run on the numbers shown.
choose one
1question 1
An empty table of 7 slots puts in 3, 10, 17, 24 and 31, all with home 3. How many probes do the five puts make in all?
the answer, and why
the answer is A
3 takes slot 3, 1 probe. Each of the others has its own step, 1, 3, 5 and 2, and finds slot 3 taken, then a free slot. 1 + 2 + 2 + 2 + 2 is 9.
step 17 of 21
31 leaves 3 when divided by 7, so its home is slot 3.
slots looked at: 0
step 18 of 21
31 leaves 1 when divided by 5, so its step is 2: each move goes 2 slots on, round to the start.
slots looked at: 0
step 19 of 21
Slot 3 holds 3, not 31.
slots looked at: 1
step 20 of 21
Slot 5 is free, so put 31 there.
slots looked at: 2
Operation 5 puts 31 in, step 2. Slot 3 holds 3, and slot 5 is free. 2 probes, though four numbers came first.
if you chose another
BThat walks one slot on each time, as linear probing does, 1 + 2 + 3 + 4 + 5.
CThat counts 1 probe a put, but each after 3 finds slot 3 taken.
DThat counts 2 probes for 3 too, but its home is free.
An empty table of 7 slots puts in 17 and 10, then 24. Which slot does 24 go in?
the answer, and why
the answer is A
17 takes slot 3. 10, home 3 and step 1, takes slot 4. 24 has home 3 and step 5. Slot 3 holds 17, and 3 + 5 is 8, which leaves 1 after dividing by 7. Slot 1 is free.
if you chose another
BSlot 4 already holds 10. 24's step is 5, so from slot 3 it moves to slot 1.
CSlot 3 is 24's home, but 17 already holds it.
DThat walks one slot on each time, 3, 4, 5, as linear probing does. 24's step is 5.