Quick Sort Algorithm
Quick Sort: Quick Sort algorithm is based on divide-and-conquer approach, recursively processing small and small parts of array list at each level. Here is the three-step divide-and-conquer process for sorting a typical subarray A[p....r]. Divide: Partition(rearrange) the array A[p ...r] into two sub-arrays A[p ...q-1] and A[q+1 ...r] such that each element of A[p...q-1] is less than and or equal to A[q], which is, in turn less than and or equal to A[q+1 ..r]. Compute the index q as part of this partitioning procedure. Conquer: Sort the two subarray A[p ...q-1] and A[q+1 ..r] by recursive calls of quicksort. Combine: Subarrays are sorted in place, no work is needed to combine them. Quick Sort algorithm chooses an element as a pivot. And partitions the given array around choose the pivot element. There are many ways to choose a pivot element for partition. Always choose the first element as a pivot. Always choose the last element as a pivot. Choose a random element a