2 ms·
Mergesort is best because it is the most elegant and beautiful sorting algorithm. Just merge lists so that they stay sorted. Quicksort has all sorts of nonsens
by bee_rider 2y ago
Mergesort is best because it is the most elegant and beautiful sorting algorithm. Just merge lists so that they stay sorted.
Quicksort has all sorts of nonsense bouncing around and picking pivots. Eww. Terrible.
I will admit that I could have been more clear that I was evaluating algorithms based on beauty, but given that info I’m sure the conclusion is obvious.
- ncruces 2y agoNow build me a selection algorithm out of mergesort. Just the other day I sped up a process by an order of magnitude because someone was sorting to do weighted median selection. Which is easy to build on top of std::nth_element. Top-k is another common need. Quicksort is still worthy today also because of this.
- Retric 2y agoOr you could just have people study QuickSelect and gain the same benefit without wasting on a slower sorting method when taking into account cache etc.