Skip to content
Mad4Study

Engineering & Science

GATE Computer Science

  • GATE CS
  • 2026–27 pattern practice
  • Algorithms
  • Recurrences
  • Easy

What is the solution of T(n)=T(n−1)+nT(n) = T(n-1) + n, with T(1)=1T(1) = 1?

Asymptotic Analysis

Pick an option to check your answer.

Unroll the recurrence:

T(n)=n+(n−1)+⋯+2+1=n(n+1)2=Θ(n2)T(n) = n + (n-1) + \cdots + 2 + 1 = \frac{n(n+1)}{2} = \Theta(n^2)

This is the cost pattern of insertion sort or selection sort in the worst case.

Why not the others

  • Θ(n)\Theta(n) would need constant work per step, as in T(n)=T(n−1)+1T(n) = T(n-1) + 1.
  • Θ(nlog⁡n)\Theta(n\log n) comes from halving recurrences like 2T(n/2)+n2T(n/2) + n.
  • Θ(2n)\Theta(2^n) comes from branching recurrences like 2T(n−1)+12T(n-1) + 1.

Report an error

GATE CS · Algorithms · Asymptotic Analysis