Tag Info

New answers tagged


In this formula O, the time value, is rarely 1. More importantly, for the time value may be different for different algorithms. An algorithm which scales linearly, O(n), may be significantly slower than an algorithm that scales quadratically, O(n^2). Knowing the Big O notation relative time values for different algorithms and expected sizes of n can help ...


O(n^2) means that if you increase n from 1000 to 10000 the number of operations will be around 10^2=100 times bigger (in your case around 50,000,000 operations).


Since the result of your (fixed) code still confuses you, i try to answer your question: The O-Notation is not an exact formula notation. Only because something is O(1) doesn't mean it takes one single step, only because it is O(n²) doesn't mean it takes n² steps. The O-Notation is an abstract way to define how complex an algorithm is. Sure, you don't get ...

Top 50 recent answers are included