Does std::sort implement Quicksort? [duplicate]

There are two algorithms that are traditionally used.

std::sort is most likely to use QuickSort, or at least a variation over QuickSort called IntroSort, which “degenerates” to HeapSort when the recursion goes too deep.

From the standard:

Complexity: O(N log(N)) comparisons.

std::stable_sort is most likely to use MergeSort, because of the stability requirement. However note that MergeSort requires extra space in order to be efficient.

From the standard:

Complexity: It does at most N log2(N) comparisons; if enough extra memory is available, it is N log(N).

I have yet to see a std::sort implementing TimSort which is promising and has been adopted in Python (crafted for it in fact), Java and Android (to date).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)