ProgrammingHard
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 inserts?
- A. 10
- B. 3
- C. 17
- D. 7
Correct answer: C. 17
Each new node is placed at the front of its chain, so the last key inserted, 17, is first.
More C Programming questions
- 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?
- A djb2-style string hash starts with h = 5381 and for each character computes h = h 33 + c (unsigned 32-bit wrap). What is the hash of "ab"?