A
A
askogorev2013-11-25 15:19:41
Algorithms
askogorev, 2013-11-25 15:19:41

Why is Quick Sort selected for the standard sort?

Good afternoon, quite a lot where (for example STL) sorting qsort is chosen as a standard sort. Question - why?
Here is an article about sorting: http://en.wikipedia.org/wiki/Sorting_algorithm
It can be seen that, for example, heap sort (Heapsort) has complexity n * log (n) in the worst case, and qsort is all n ^ 2. So why exactly qsort?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
F
forgotten, 2013-11-25
@forgotten

Because qsort has the best coefficient at n*log(n)

J
JSinga, 2013-11-25
@JSinga

Do not read Wikipedia, read the original - Kormen , you still need to read it, it comes in handy no matter what))
Needless to say that this is a book from the category of "mandatory reading".
If you like, you can go deeper - Knut

N
nekipelov, 2013-11-25
@nekipelov

Heapsort is always O(n log n). And quck sort often sorts faster. But not always, so the STL uses Introsort.

I
Igor, 2013-11-26
@leotop

It is optimal for most typical tasks. Optimal does not mean the fastest, it means that it solves the problem in an acceptable time.
For example:

Timsort is a hybrid sorting algorithm.
The main idea of ​​the algorithm is that in the real world sorted data arrays often contain ordered subarrays. On such data, Timsort is significantly faster than many sorting algorithms.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question