GATE Computer ScienceHardGATE CS (PYQ pattern)

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)?

  1. A. Θ(n log n)
  2. B. Θ(log n)
  3. C. Θ(n)
  4. D. Θ(n log² n)

Correct answer: A. Θ(n log n)

Divide by n + 1: T(n)/(n+1) = T(n−1)/n + 1/(n+1). So U(n) = T(n)/(n+1) = 1/2 + Σ_{k=3}^{n+1} 1/k = Θ(log n), giving T(n) = Θ(n log n). Treating the factor (1 + 1/n) as 1 gives Θ(n).

More Algorithms questions

Exams that ask this topic