ProgrammingVery hard
A chained hash table is resized by doubling whenever it becomes full, starting at capacity 1. Inserting 8 keys, how many element moves does the resizing do in total?
- A. 8
- B. 4
- C. 7
- D. 15
Correct answer: C. 7
Resizes happen when inserting the 2nd, 3rd and 5th keys, and they move 1, 2 and 4 elements. 1 + 2 + 4 = 7, which is less than 8.
More C Programming questions
- Keys 8, 16, 24 and 32 are hashed with h(k) = k % 8 and then with h(k) = k % 7. Which statement is correct?
- With 10^5 keys and a load factor of at most 0.5, what is the smallest power-of-two table size that works?
- Keys 13 and 23 are inserted with linear probing into a table of size 10 with h(k) = k % 10. In which slot does 23 land?
- Keys 6, 1 and 11 are inserted with linear probing into a table of size 5, h(k) = k % 5. In which order do the keys appear when the table…
- With chaining, what is the expected number of nodes examined by an unsuccessful search when the load factor is 1.5?
- A hash table with 10 buckets receives 11 keys. What is the minimum number of collisions guaranteed?