问题
While(n>1)
{
n=n/20;
n=n/10;
}
I tried like this =>
Here, n = n/200 which means that N is getting reduced each time by a factor of 200. so, time complexity = O(log base 200 N)
回答1:
Yes, n gets reduced to 1/200 each time in the loop.
So, this loop would run log 200 n times.
Hence, time-complexity = O(log 200 n).
来源:https://stackoverflow.com/questions/39324836/what-is-the-time-complexity-of-given-code