But (and that's a pretty big but), 'Big O' is not all there is, and once you've picked your algorithm based on the one that has the best expected runtime based on 'Big O', you really have to try to make sure that:
- your algorithm is executed with the lowest possible frequency
- you concentrate on those pesky n's that you eliminated during analysis to
make sure that you don't end up wasting all your CPU time on some
little detail somewhere
- you take in to account the effects of your code on caches and virtual memory
- you profile your code afterwards to make sure that all your assumptions regarding
the above are correct
It is very easy to pick the 'right' algorithm and still get crappy runtime if you skip those steps.