Data Structures & AlgorithmsVery hardHCLTech · Wipro pattern

Keys 93, 67, 60, 15, 3, 58, 52, 13, 92 are inserted via separate chaining (h(k) = k mod 7, new keys appended to the end of the chain) into a table of size 7 (buckets 0 to 6). What are the final bucket contents, and what is the longest chain length?

  1. A. ∅, 92→15, 58→93, 52→3, 60→67, ∅, 13 — longest chain 2
  2. B. ∅, 15→92, 93→58, 3→52, 67→60, ∅, 13 — longest chain 2
  3. C. ∅, 15→92, 93→58, 3→52, 67→60, ∅, 13 — longest chain 1
  4. D. 52, 15, 93, 3, 67, 60, 58 — longest chain 1

Correct answer: B. ∅, 15→92, 93→58, 3→52, 67→60, ∅, 13 — longest chain 2

Each key is appended to the chain at index k mod 7 in insertion order, giving buckets [∅, 15→92, 93→58, 3→52, 67→60, ∅, 13], whose longest chain has 2 key(s). This differs from open addressing (linear probing), which would spread keys like [52, 15, 93, 3, 67, 60, 58] into single-slot buckets instead of chains.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic