Given following recursive equation:
$$T(n) = T(n-3) + \Theta(1)$$
Is it correct that this equation is O(1)?
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)$.
Copyright © 2021 JogjaFile Inc.
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)$.