Reputation: 689
While(n>=1)
{
n=n/20;
n=n/6;
n=10×n;
n=n-10000;
}
I tried like this =>
In this loop, N gets reduced by N/12 - 10000. so, time complexity is O(log N).
Upvotes: 5
Views: 256
Reputation: 13608
That seems to be correct. If this is an exercise, you should be prepared to argue why O(log_12(N))
is O(log(N))
.
Upvotes: 6