GATE Computer ScienceHardGATE CS (PYQ pattern)

Let T(n) = 2T(n/2) + n·log₂ n for n ≥ 2, T(1) = 1, with n = 2^k. Which is the exact closed form of T(n)?

  1. A. n·(1 + k(k−1)/2)
  2. B. n·k(k+1)/2
  3. C. n·(1 + k²/2)
  4. D. n·(1 + k(k+1)/2)

Correct answer: D. n·(1 + k(k+1)/2)

Divide by n: U(k) = T(2^k)/2^k satisfies U(k) = U(k−1) + k, U(0) = 1, so U(k) = 1 + (1 + 2 + … + k) = 1 + k(k+1)/2. Check k = 1: T(2) = 2·1 + 2·1 = 4 = 2·(1 + 1). The k(k−1)/2 form sums one level too few; dropping the 1 forgets the n leaves.

More Algorithms questions

Exams that ask this topic