<Dd> Instead of partitioning into two subarrays using a single pivot, multi-pivot quicksort (also multiquicksort) partitions its input into some s number of subarrays using s − 1 pivots . While the dual - pivot case (s = 3) was considered by Sedgewick and others already in the mid-1970s, the resulting algorithms were not faster in practice than the "classical" quicksort . A 1999 assessment of a multiquicksort with a variable number of pivots, tuned to make efficient use of processor caches, found it to increase the instruction count by some 20%, but simulation results suggested that it would be more efficient on very large inputs . A version of dual - pivot quicksort developed by Yaroslavskiy in 2009 turned out to be fast enough to warrant implementation in Java 7, as the standard algorithm to sort arrays of primitives (sorting arrays of objects is done using Timsort). The performance benefit of this algorithm was subsequently found to be mostly related to cache performance, and experimental results indicate that the three - pivot variant may perform even better on modern machines . </Dd> <Dl> <Dt> External quicksort </Dt> <Dd> The same as regular quicksort except the pivot is replaced by a buffer . First, read the M / 2 first and last elements into the buffer and sort them . Read the next element from the beginning or end to balance writing . If the next element is less than the least of the buffer, write it to available space at the beginning . If greater than the greatest, write it to the end . Otherwise write the greatest or least of the buffer, and put the next element in the buffer . Keep the maximum lower and minimum upper keys written to avoid resorting middle elements that are in order . When done, write the buffer . Recursively sort the smaller partition, and loop to sort the remaining partition . This is a kind of three - way quicksort in which the middle partition (buffer) represents a sorted subarray of elements that are approximately equal to the pivot . </Dd> </Dl> <Dd> The same as regular quicksort except the pivot is replaced by a buffer . First, read the M / 2 first and last elements into the buffer and sort them . Read the next element from the beginning or end to balance writing . If the next element is less than the least of the buffer, write it to available space at the beginning . If greater than the greatest, write it to the end . Otherwise write the greatest or least of the buffer, and put the next element in the buffer . Keep the maximum lower and minimum upper keys written to avoid resorting middle elements that are in order . When done, write the buffer . Recursively sort the smaller partition, and loop to sort the remaining partition . This is a kind of three - way quicksort in which the middle partition (buffer) represents a sorted subarray of elements that are approximately equal to the pivot . </Dd> <Dl> <Dt> Three - way radix quicksort </Dt> </Dl>

Write the algorithm of quick sort and calculate the complexity of quick sort in worst case