Home /
Expert Answers /
Computer Science /
quicksort-is-a-divide-and-conquer-algorithm-it-works-by-selecting-a-39-pivot-39-element-from-the-arr-pa430
(Solved): Quicksort is a divide-and-conquer algorithm. It works by selecting a 'pivot' element from the array ...
Quicksort is a divide-and-conquer algorithm. It works by selecting a 'pivot' element from the array and partitioning the other elements into two sub-arrays, according to whether they are less than or greater than the pivot. For this reason, it is sometimes called partition-exchange sort. The sub-artays are then sorted recursively. This can be done in-place, requiring small additional amounts of memory to perform the sorting. The procedure can be represented in pseudo code: PseudoQuickSort Input: A list \( L=[a 1, \ldots, a n] \) of distinet integers or an empty list []. If \( : n=1 \) or \( L \) is empty, return L. Else: - Set \( p=a 1 \) (p is the 'pivot'). - Set \( L \mathrm{I}=\|, L 2=\| \). For: \( 2 \leq i \leq n_{1} \) If: \( a i