What is the time complexity of this code?

While(n>=1) { n=n/20; n=n/6; n=10×n; n=n-10000; } 

I tried like this =>

In this cycle, N decreases by N / 12 - 10,000. Therefore, the time complexity is O (log N).

+5
source share
1 answer

That seems right. If this is an exercise, you should be prepared to argue why O(log_12(N)) is O(log(N)) .

+6
source

All Articles