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?
- A. 11
- B. 29
- C. 9
- 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
- Cocktail-shaker sort is applied to [5, 1, 4, 2, 8, 0, 3]: sweeps alternate left-to-right and right-to-left over the unsorted part (each…
- In randomised quicksort on n = 10 distinct keys (pivot chosen uniformly, so two keys with ranks i < j are compared with probability 2/(j −…
- Multiplying two n × n matrices classically costs n³ multiplications and n²(n − 1) additions. One level of Strassen (7 products of n/2 ×…
- Karatsuba multiplies two n-digit numbers (n = 2^k) with 3 half-size products, recursing down to 1-digit numbers; the classical method uses…
- Let T(1) = 1 and T(n) = (1 + 1/n)·T(n − 1) + 1 for n ≥ 2. Which is the tight bound on T(n)?
- The running time satisfies T(n) = T(n/2) + T(n/3) + T(n/6) + n. Which bound is tight?