advanced sorting algorithm description the quick sort is simple recursive algorithm that can be used to sort keys stored in either an array or list given the sequenceit performs the following steps the first key is selected as the pivotp the pivot value is used to partition the sequence into two segments or subsequencesl and gsuch that contains all keys less than the and contains all keys greater than or equal to the algorithm is then applied recursively to both and the recursion continues until the base case is reachedwhich occurs when the sequence contains fewer than two keys the two segments and the pivot value are merged to produce sorted sequence this is accomplished by copying the keys from segment back into the original sequencefollowed by the pivot value and then the keys from segment after this stepthe pivot key will end up in its proper position within the sorted sequence an abstract view of the partitioning stepin which much of the actual work is doneis illustrated in figure you will notice the size of the segments will vary depending on the value of the pivot in some instancesone segment may not contain any elements it depends on the pivot value and the relationship between that value and the other keys in the sequence when the recursive calls returnthe segments and pivot value are merged to produce sorted sequence this process is illustrated in figure figure an abstract view showing how quick sort partitions the sequence into segments based on the pivot value (shown with gray background