ProgrammingHard
A hash table of size 5 uses h(k) = k mod 5 with linear probing. The keys 5, 10, 15 and 3 are inserted in that order into an empty table. How many of these insertions needed at least one extra probe?
- A. 1
- B. 2
- C. 3
- D. 4
Correct answer: B. 2
10 and 15 both hash to slot 0 and must probe further. 5 and 3 land in their home slots.
More C Programming questions
- A chained table has 4 buckets with h(k) = k % 4. Keys 1 and 5 are inserted with head insertion. Which key is first in bucket 1?
- A hash table starts with capacity 8 and doubles whenever the count exceeds half the capacity. After 9 insertions, what is the capacity?
- In a linear-probing table, slot 1 holds a tombstone and slot 2 holds key 6. A search for 6 begins at slot 1 (its hash). How many slots are…
- A singly linked list of five nodes 1 -> 2 -> 3 -> 4 -> 5 has the node with value 3 unlinked and freed. How many nodes remain?
- Deleting a node from the middle of a doubly linked list of length n costs what, if a pointer to the node is already known?
- A chained table with 10 buckets holds 30 keys. What is the average chain length?