What is Big O notation? Do you use it?
I missed this university class I guess 😀
Does anyone use it and give some real life examples of where they used it?
See also:
Big-O for Eight Year Olds?
Big O, how do you calculate/approximate it?
Did you apply computational complexity theory in real life?
One important thing most people forget when talking about Big-O, thus I feel the need to mention that:
You cannot use Big-O to compare the speed of two algorithms. Big-O only says how much slower an algorithm will get (approximately) if you double the number of items processed, or how much faster it will get if you cut the number in half.
However, if you have two entirely different algorithms and one (
A) isO(n^2)and the other one (B) isO(log n), it is not said thatAis slower thanB. Actually, with 100 items,Amight be ten times faster thanB. It only says that with 200 items,Awill grow slower by the factorn^2andBwill grow slower by the factorlog n. So, if you benchmark both and you know how much timeAtakes to process 100 items, and how much timeBneeds for the same 100 items, andAis faster thanB, you can calculate at what amount of itemsBwill overtakeAin speed (as the speed ofBdecreases much slower than the one ofA, it will overtakeAsooner or later—this is for sure).