There are some common Big-O notations that you should become familiar with as well as what kind of code leads to them. This episode continues the discussion of Big-O notation so make sure to listen to episode 37 first. Knowing the signs of these will help you write more efficient code and for some of them could actually mean the difference between your program working vs. never completing at all.
Here are the Big-O notations in order of execution speed from fastest to slowest:
Big-O (1) runs in constant time no matter how big your problem becomes.
Big-O (lg N) runs in time proportional to the log of N.
Big-O (N) runs in time proportional to N.
Big-O (N lg N) runs in time proportional to N times the log of N. this will be a little slower than just N.
Big-O (N2) runs in time proportional to N times N. You might also find varieties of this such as Big-O (N3)
Big-O (N!) forget about this completing at all for items in the mid to upper teens. This really starts becoming impractical with N as small as just 10.
Note that there are more Big-O notations than just these. But learning these will help you understand almost all the situations you’re likely to encounter. And hopefully, you don’t come across N factorial at all.