Answer the question
In order to leave comments, you need to log in
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
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
Heapsort is always O(n log n). And quck sort often sorts faster. But not always, so the STL uses Introsort.
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 questionAsk a Question
731 491 924 answers to any question