3
C-sucks
3y

Quicksort has never been such bullsh*t before

Comments
  • 1
    Quicksort should not have changed ;)
  • 0
    What's the issue with quicksort? A robust implementation? The vanilla version isn't really good in practice due to pathological corner cases.
  • 1
    @Fast-Nop tbh, the implementation is quite complicated as compared to merge-sort
  • 4
    @C-sucks That's because vanilla quicksort isn't robust. The choice of the pivot element is crucial, but it's also guesswork. By consequence, quicksort may degrade into O(n) recursion depth with carefully chosen data, which would likely result in a stack overflow with large data. That's why real quicksorts have quite some hackery including switching to some other algo internally upon certain conditions.

    It's also why qsort() in embedded systems doesn't use quicksort, but rather e.g. shellsort or heapsort, depending on whether maximum performance or low execution time variance (for a given N) is more important.
Add Comment