Objective: Write an algorithm to sort an array in increasing or decreasing order using Quick Sort.
Input: An Array arrA
Output: A sorted array.
- Choose any element from the array and call it as pivot element, Example here we have selected middle element as pivot
- Place all the elements smaller than pivot in the left side of pivot.
- Place all the elements greater than pivot in the right side of pivot.
- Sort left side and right side recursively.
UnSorted : 2 1 8 4 0 9 3 11 Quick Sorted : 0 1 2 3 4 8 9 11