ProgrammingVery hard
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. The program deletes 0 by setting slot 0 to empty. What does find(7) return?
- A. found at slot 1
- B. not found, because the search stops at the empty slot 0
- C. found at slot 0
- D. it loops forever
Correct answer: B. not found, because the search stops at the empty slot 0
A lookup stops at the first empty slot, so emptying slot 0 hides 7 even though it sits at slot 1. Deletion needs a tombstone marker, not an empty slot.
More C Programming questions
- 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…
- A quadratic probing table of size 8 starts at h = 2 and uses probe i checks (h + ii) % 8 for i = 0, 1, 2, 3. What index is checked at i = 2?