ProgrammingVery hard
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"?
- A. 5863208
- B. 177670
- C. 5863210
- D. 5863206
Correct answer: A. 5863208
After 'a' the value is 5381 x 33 + 97 = 177670. For 'b' it is 177670 x 33 + 98 = 5863208. No wrap happens at this size.
More C Programming questions
- Which expression always gives a valid bucket index in the range 0 to m - 1 for a signed int key k, with m > 0?
- A chained hash table is resized by doubling whenever it becomes full, starting at capacity 1. Inserting 8 keys, how many element moves…
- 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…