What is the complexity of this function?
T(n) = T(n/3) + 1
Is the answer is O(n). But how the step?
Ok, so this is my answer:
T(n) = T(n/3) + 1
I use master theorem here,
So it got T(n) = aT(n/b) + f(n)
Compare the n^logb(a) with the f(n)
a = 1, b = 3
n^logb(a) = n^log3(1)
= n^0
= 1
f(n) = Θ(n^logb(a))
So the solution that I got is T(n) = Θ(logn)
This is my answer, but when I searched it, it said the answer T(n) = Θ(n)
?