2 ms·
Sort of. As you go up the scale the Big-O values are almost always dominant. It's very rare to see a situation where you would choose the algorithm with the h
by LorenPechtel 4y ago
Sort of.
As you go up the scale the Big-O values are almost always dominant. It's very rare to see a situation where you would choose the algorithm with the higher value.
However, when two algorithms have the same Big-O there can still be a big difference in performance, especially in the face of how a cache influences things.
(There are cases where the memory accesses are so important that they can make the "bad" approach better. A while back I did some time testing and found the Sieve of Eratosthenes inferior to brute force because of all the cache misses.)
- bluefirebrand 4y agoAt a certain point your best bet is really to profile the two approaches to see which performs better. But if you are starting out with nothing built and only have time to write one, you can't really go wrong by going with the one with the better Big O. If it's the same, coin toss I guess. :)