What is the difference between the built-in qsort function and the stable sort function?

From the various sources quoted, I know that the built-in C function, stable_sort is stable, but qsort is unstable. If so, then why do we use qsort at all? Isn't that redundant? Why not use stable_sort instead?

+4
source share
3 answers

The reason for choosing fast sorting by stable sorting is mainly speed: qsortoften faster stable_sort, which should appear as not surprising, because it stable_sorthas a stronger guarantee.

O (N ยท < > 2 > (N)). , - O (N ยท log (N)).

- : qsort , , . stable_sort, , , .

, , , . , .

rcgldr : ( HP/Microsoft std::stable_sort 1/2 . , , .

+7

, . .

, , / .
merge sort.

+9

, qsort?

stable_sort() C. qsort() C.

C qsort() .

qsort() , . qsort() , , . , . , , .

0

Source: https://habr.com/ru/post/1608313/


All Articles