GATE Computer ScienceVery hardGATE CSE

A hash table with 7 buckets uses separate chaining, h(k) = k mod 7, and every new key is inserted at the head of its chain. The keys 50, 700, 76, 85, 92, 73, 101, 14, 28, 35, 21, 49, 63 are inserted in that order. If every key is then searched once, how many key comparisons are made in total (a successful search counts the comparison with the found key)?

  1. A. 41
  2. B. 34
  3. C. 47
  4. D. 38

Correct answer: D. 38

Chains (head first): [63,49,21,35,28,14,700] [92,85,50] [] [101,73] [] [] [76]; the position of each key in its chain sums to 38.

More Programming and Data Structures (GATE) questions

Exams that ask this topic