3 ms·
After seeing a lot of peers being mislead by big O I think most of big O articles on the web, for the sake of clarity or simplicity omits to express one thing
by allan_s 10y ago
After seeing a lot of peers being mislead by big O I think most of big O articles on the web, for the sake of clarity or simplicity omits to express one thing
if we admits functions
* square_big_o O(n²)
* linear_big_o O(n)
then the statement
time(squarre_big_o(x)) > time(linear_big_0(x))
is not necessary true for every value of x
because the actual complexity could be
* 1000+1000*N
* 2+N²
in which case most of the time you will chose the square one, because practically it will be faster.
without this in mind, you got peer who tell you that this thing is faster because the algorithm is O(n) versus O(n²), though we're talking about a function that will always have n < 10, but yesterday night they read an article about big O and now they have to throw a "let's think about the big O" remarks for every single problem we meet
- Bahamut 10y agoExcept if one knows what the definition of big O is, there is nothing to be misled by. What big O tells you is what is the function bounded by after a constant lower bound on the input. One always want to do performance testing to see whether it comes into play even when it comes to more practical applications such as in code.