by hellofunk · 10y ago · 0 comments
What's in the parenthesis is not a measure of a unit of time, which is why Big-O fanatics often miss the bigger picture.
Well, I'm not trying to miss the bigger picture, but if you're going to scale that your O(n) algorithm will quickly take longer than a O(1) algorithm.
I mean, let's just take a hashtable as example. This hash takes 1 hour to complete while you can search the list in milliseconds.
But what if the list has billions and billions of entries and it takes longer than 1 hour?
As some others said, Big-O is not something you use to choose one algorithm over the other, it's something you use to choose an algorithm that scales well and has acceptable performance.
O(n) vs O(1) is a rather tame comparison, what if your competing algorithm is a O(n!) or worse?