ProgrammingVery hard
Which operation is needed to make open addressing deletions safe for later lookups?
- A. Set the deleted slot to zero, which marks it empty
- B. Move every later key one slot back without checking
- C. Mark the deleted slot with a tombstone so probing continues past it
- D. Skip the deletion and mark the key as absent elsewhere
Correct answer: C. Mark the deleted slot with a tombstone so probing continues past it
A tombstone keeps the probe sequence unbroken while still allowing insertion into the slot. Emptying it stops later searches early.
More C Programming questions
- A program counts the distinct keys among 10^6 values by inserting them into a hash set with expected O(1) operations. What is the expected…
- Which property of the hash function matters most to avoid long chains when keys are multiples of 8 and the table has 8 buckets?
- A table of size 7 with h(k) = k % 7 is filled with 7 keys using linear probing and no deletions. How many more keys can be inserted before…
- Which search code is correct for an open-addressing table of size m with linear probing, where an empty slot ends the search?
- A hash table stores pointers to nodes allocated with malloc. What must happen when the table is destroyed?
- The expected number of probes for an unsuccessful search in linear probing with load factor a = 0.9 is about what?