quick-sort the next sorting algorithm we discuss is called quick-sort like merge-sortthis algorithm is also based on the divide-and-conquer paradigmbut it uses this technique in somewhat opposite manneras all the hard work is done before the recursive calls high-level description of quick-sort the quick-sort algorithm sorts sequence using simple recursive approach the main idea is to apply the divide-and-conquer techniquewhereby we divide into subsequencesrecur to sort each subsequenceand then combine the sorted subsequences by simple concatenation in particularthe quick-sort algorithm consists of the following three steps (see figure ) divideif has at least two elements (nothing needs to be done if has zero or one element)select specific element from swhich is called the pivot as is common practicechoose the pivot to be the last element in remove all the elements from and put them into three sequenceslstoring the elements in less than estoring the elements in equal to gstoring the elements in greater than of courseif the elements of are distinctthen holds just one element-the pivot itself conquerrecursively sort sequences and combineput back the elements into in order by first inserting the elements of lthen those of eand finally those of split using pivot ( recur recur (xg( concatenate figure visual schematic of the quick-sort algorithm