Correctness of complexity analysis of recursive algorithm

89 Views Asked by At

Given following recursive equation:

$$T(n) = T(n-3) + \Theta(1)$$

Is it correct that this equation is O(1)?

1

There are 1 best solutions below

1
On BEST ANSWER

You apply the recursive equation approximately $n/3$ times to get down to the base case, and each time you apply the equation you get a $\Theta(1)$ contribution. Thus the complexity is $T(n) = \Theta(n)$.