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"?

  1. A. 5863208
  2. B. 177670
  3. C. 5863210
  4. 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

Exams that ask this topic