GATE Computer ScienceEasyGATE CS (PYQ pattern)

Two sorted lists of 5 and 7 distinct keys are to be merged into one sorted list by comparisons. What does the decision-tree (information-theoretic) argument give as a lower bound on the worst-case number of comparisons?

  1. A. 11
  2. B. 29
  3. C. 9
  4. D. 10

Correct answer: D. 10

The number of possible interleavings is C(12, 5) = 792, and a binary decision tree with 792 leaves has height at least ⌈log₂ 792⌉ = 10 (2⁹ = 512 < 792 ≤ 1024). 11 = 5 + 7 − 1 is what the standard merge uses; 29 is the bound for fully sorting 12 keys.

More Algorithms questions

Exams that ask this topic