The quick sort algorithm was developed by C. A. R. Hoare while in the Soviet Union, as a visiting
student at Moscow State University. At that time, Hoare worked in a project on machine translation for the National Physical Laboratory. He developed the algorithm in order to sort the words to betranslated, to make them more easily matched to an already-sorted Russian-to-English dictionary thatwas stored on magnetic tape
Comparison with other sorting algorithms
Quick sort is a space-optimized version of the binary tree sort. Instead of inserting items sequentiallyinto an explicit tree, quick sort organizes them concurrently into a tree that is implied by the recursivecalls. The algorithms make exactly the same comparisons, but in a different order.The most direct competitor of quick sort is heap sort . Heap sorts worst-case running time is alwaysΘ(
). But, heap sort is assumed to be in average somewhat slower than quick sort. This is stilldebated and in research, with some publications indicating the opposite. In Quick sort remains thechance of worst case performance except in the intro sort variant, which switches to heap sort when abad case is detected. If it is known in advance that heap sort is going to be necessary, using it directlywill be faster than waiting for intro sort to switch to it.Quick sort also competes with merge sort, another recursive sort algorithm but with the benefit of worst-case Θ(
) running time. Merge sort is a stable sort , unlike quick sort and heap sort, and canbe easily adapted to operate on linked lists and very large lists stored on slow-to-access media such asdisk storage or network attached storage. Although quick sort can be written to operate on linked lists,
it will often suffer from poor pivot choices without random access. The main disadvantage of mergesort is that, when operating on arrays, it requires Θ(
) auxiliary space in the best case, whereas thevariant of quick sort with in-place partitioning and tail recursion uses only Θ(log
) space. (Note that
when operating on linked lists, merge sort only requires a small, constant amount of auxiliary storage.)Bucket sort with two buckets is very similar to quick sort; the pivot in this case is effectively the value
in the middle of the value range, which does well on average for uniformly distributed inputs.
is a sorting algorithm with extremely good O(n) efficiency for balanced data sets, publishedin 1998 by Karl-Dietrich Neubert.
Flash sort works based on the principle that in either a randomized or partially-ordered data set inwhich data are in a balanced distribution, one can immediately estimate where an item should be placedwhen one knows the range of the set. This approximate location is called the
of an item