ProgrammingVery hard
A table of size 7 uses h(k) = k % 7 with linear probing. Keys 14, 21, 7 and 0 are inserted in that order. In which slot does key 0 land?
- A. 3
- B. 2
- C. 4
- D. 0
Correct answer: A. 3
14 takes slot 0, 21 probes to slot 1, 7 probes to slot 2 and 0 probes through slots 0, 1 and 2 to reach slot 3.
More C Programming questions
- Linear probing with a tombstone-free delete: keys 0 and 7 both hash to slot 0 in a table of size 7. 0 is stored at slot 0 and 7 at slot 1…
- Chaining with head insertion: keys 10, 3 and 17 all hash to bucket 3 in a table of size 7. Which key is first in the chain after the three…
- With linear probing at load factor 0.5, the expected number of probes for an unsuccessful search, under uniform hashing, is what?
- With linear probing at load factor 0.75, the expected number of probes for an unsuccessful search, under uniform hashing, is what?
- A chained table has 10 buckets holding 20 keys, and a successful search examines the matching key uniformly at random. What is the…
- A table of size 10 uses linear probing. Keys 5, 15 and 25 are inserted in that order with h(k) = k % 10. How many slots are examined in…