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).
When we analyse an algorithm, we use a notation to represent its time complexity and that notation is Big O notation. For Example: time complexity for Linear search can be represented as O(n) and O(log n) for Binary search (where, n and log(n) are the number of operations).
O(N^2)
O(1) — Constant Time The execution time of these algorithm is independent of the size of the input. A good example of O(1) time is accessing a value with an array index. Other examples include: push() and pop() operations on an array.
How is time complexity measured? By counting the number of algorithms in an algorithm. By counting the number of primitive operations performed by the algorithm on a given input size. By counting the size of data input to the algorithm.
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))
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With