GATE Computer ScienceHardGATE CS (PYQ pattern)

Let T(n) = T(n/2) + n(2 − cos n) (n in radians) with T(1) = 1. Which statement about T(n) is correct?

  1. A. T(n) = Θ(n log n), because cos n oscillates
  2. B. T(n) = Θ(n), even though the regularity condition fails
  3. C. T(n) = Θ(1), because the cos term cancels
  4. D. The recurrence has no asymptotic bound

Correct answer: B. T(n) = Θ(n), even though the regularity condition fails

Since 1 ≤ 2 − cos n ≤ 3, the f term lies between n and 3n, so T(n) is between n and 6n by unrolling the geometric series: Θ(n). The regularity condition of the master theorem cannot be verified because f oscillates, but the direct bound still works.

More Algorithms questions

Exams that ask this topic