Data Structures & AlgorithmsEasyInfosys · Capgemini pattern

A hash table has 7 slots and uses h(k) = k mod 7. In which slot is the key 50 placed if that slot is empty?

  1. A. 7
  2. B. 0
  3. C. 1
  4. D. 6

Correct answer: C. 1

50 = 7 × 7 + 1, so 50 mod 7 = 1. Slot indices run 0–6, so '7' is not even a valid slot; the quotient is 7, not the remainder.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic