vergesort icon indicating copy to clipboard operation
vergesort copied to clipboard

Use a mergesort-backed introsort for the bidirectional iterators vergesort

Open Morwenn opened this issue 10 years ago • 0 comments

Currently, the vergesort overloads that deals with bidirectional iterators uses a regular median-of-3 pivot quicksort as a fallback sorting algorithm. Unfortunately, even if the median-of-3 pivot makes it harder to exhibit a quadratic behaviour, such a behaviour can still potentially occur.

Would it be a good idea to make the vergesort fall back onto a mergesort-backed introsort instead of a median-of-3 pivot quicksort? Such an algorithm would be really similar to an introsort, except it would fall back on a mergesort while a regular introsort falls back on a heapsort (which requires random-access iterators). Of course, a mergesort uses more memory than a heapsort, but this shouldn't be a big problem since the vergesort may already consume more than O(1) extra memory.

Morwenn avatar Oct 21 '15 00:10 Morwenn