Search code examples
algorithmarray-algorithms

How to calculate O(log n) in big O notation?


I know that O(log n) refers to an iterative reduction by a fixed ratio of the problem set N (in big O notation), but how do i actually calculate it to see how many iterations an algorithm with a log N complexity would have to preform on the problem set N before it is done (has one element left)?


Solution

  • You can't. You don't calculate the exact number of iterations with BigO.

    You can "derive" BigO when you have exact formula for number of iterations.

    BigO just gives information how the number iterations grows with growing N, and only for "big" N.

    Nothing more, nothing less. With this you can draw conclusions how much more operations/time will the algorithm take if you have some sample runs.