GATE Computer ScienceVery hardGATE CS (PYQ pattern)

Let T(n) = T(n − ⌊√n⌋) + 1 for n > 1 and T(1) = 0. Which is the tight bound?

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

Correct answer: C. Θ(√n)

While n shrinks from N to N/2, each step removes at least √(N/2), so that phase takes O(√N) steps, and the phases N, N/2, N/4, … cost a geometric series: Θ(√N) overall (numerically T(n)/√n → 2). It is not Θ(log n) because the steps subtract, rather than divide.

More Algorithms questions

Exams that ask this topic