Fast sorting algorithm
Fast sequencing is a sort of algorithm developed by Donny Holl. On average, sort n items to 0(n log n) comparisons. In the worst case scenario, a 0(n2) comparison is required, but this is not a common situation. In fact, fast sequencing is usually much faster than the other 0(n log n) algorithms because its internal loop (inner Loop) can be implemented efficiently on most architectures.
Quick sort uses the divide-and-conquer (Divide and conquer) strategy to divide a serial (list) into two sub-serial (sub-lists).
Algorithm steps:
1. Pick an element from the series called "Datum" (pivot),
2, reorder the series, all elements are smaller than the benchmark value placed in front of the benchmark, all elements are larger than the benchmark value of the base (the same number can be on either side). After the partition exits, the datum is in the middle of the sequence. This is called partition (partition) operation.
3. Recursively (recursive) sorts sub-columns that are smaller than the base value elements and sub-numbers that are larger than the base value elements. At the bottom of the recursive scenario, the size of the sequence is 0 or one, which is always sorted. Although it is always recursive, the algorithm always exits, because in each iteration (iteration), it will at least put an element to its last position.
Complexity of the algorithm:
Worst case scenario: Occurs when the partitioning process produces two areas containing n-1 elements and a 0 element, that is, assuming that the algorithm is present in every recursive invocation process, which is asymmetrical.
The quickest situation: that partition can do the most balanced division, the resulting sub-problem can not be greater than N/2. Because the size of one of the sub-problems is |_n/2_|. The size of the other sub-problem is |-n/2-|-1.
Specific implementation:
"Quick Sort"