Theta time complexity for loop

160 Views Asked by At

What would be the time complexity for this kind of loop in theta notation?

for (j=1; j< n^3 ; j=3*j)

Is it logn^3?

I understand independently when to use logn and when to use n^x but when combining them together, I seem to have an issue understanding the outcome.

1

There are 1 best solutions below

4
On

Yes, you are right. But note that

Log(n^3) = 3 * Log(n)

so complexity is Theta(Log(n)), because constant factor doesn't affect on asymptotic behavior.