5 ms·
This is a big assumption. See this animated example that danso posted: http://www.sorting-algorithms.com/ http://www.sorting-algorithms.com/ Yes, a difference
by trebor 14y ago
This is a big assumption.
See this animated example that danso posted: http://www.sorting-algorithms.com/ http://www.sorting-algorithms.com/
Yes, a difference of maybe 5ms won't be noticed... unless you're going a lot of sorting. Selection Sort is basically the slowest sort of all.
- calinet6 14y agoOne thing I learned when optimizing code is to never trust my intuition. That piece of code you think must be slow and must be impacting the application speed? It might not be consequential at all. Spending 4 hours optimizing it might get you exactly 0% improvement. And that one line you think is benign and would take 5 minutes to opt might end up being the key to speeding up your entire algorithm tenfold. It's important to understand speed and complexity when architecting software, but it's just as important to know how it really performs in the real world, on the CPU, with real memory constraints and real data. I'm not saying this is true at all for this particular algorithm, but it's been uncannily true for me in the past and I still fool myself to this day trying to optimise prematurely based on my primitive human computer.