Hacker News new | ask | show | jobs
by paulddraper 19 days ago
It's an in-place sort with extra space O(log n). Same as quicksort average, better than quicksort worst O(n^2).

This uses a bunch of low-level tricks and alternate stragies to beat std::sort on random data.

The primary advantage is branchless partitioning, which is a big win for random data, which hurts branch prediction for quicksort.

1 comments

quicksort worst case space bound is still O(logN) as you can tail call on the longest partition and need to maintain a stack only for the other one.
Yes. That isn't textbook quicksort. Ie, the Hoare or Lomuto quicksorts recurse both sides. [1]

But it is a sensible improvement.

(EDIT: I typoed my original comment. It O(n^2) space; worst case is O(n) space and O(n^2) time for the vanilla alg.)

[1] https://en.wikipedia.org/wiki/Quicksort