Quadsort: a stable non-recursive merge sort
1–10 of 110 posts
Re: Quadsort: a stable non-recursive merge sort
#2Re: Quadsort: a stable non-recursive merge sort
#3Re: Quadsort: a stable non-recursive merge sort
#4Re: Quadsort: a stable non-recursive merge sort
#5It seems really obvious in hindsight, so I'm sure there's just prior art I don't know about.
Re: Quadsort: a stable non-recursive merge sort
#6Benchmark of quadsort() versus C qsort():
* ~10x faster on forward-order items
* ~2x faster on reverse-order items
* ~equivalent on random-order items
Improvements:
* Ordering: when blocks of items are in order, or in reverse-order, then do special case handling, which gives quadsort O(n + log n) instead of qsort O(n * log n).
* Boundaries: compare data rather than traditional merge sort wasteful boundary checks.
Re: Quadsort: a stable non-recursive merge sort
#7Seems it's mergesort but with a slightly more complicated comparison primitive.
Re: Quadsort: a stable non-recursive merge sort
#8Re: Quadsort: a stable non-recursive merge sort
#9I've never seen a sorting algorithm that uses a non-binary comparison function to order values. Is that a novel technique? It seems really obvious in hindsight, so I'm sure there's just prior art I don't know about.
Re: Quadsort: a stable non-recursive merge sort
#10I've never seen a sorting algorithm that uses a non-binary comparison function to order values. Is that a novel technique? It seems really obvious in hindsight, so I'm sure there's just prior art I don't know about.
There are, in general, a number of different sorting algorithms which are optimized for a specific number of elements. In this case, four. It uses five binary comparisons to sort four elements.
You can find other algorithms like this, such as an algorithm that uses seven comparisons to sort five items, or one that uses ten comparisons to sort six items.