Quick Sort Implementation
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.
Output: UnSorted : 2 1 8 4 0 9 3 11 Quick Sorted : 0 1 2 3 4 8 9 11
Top Companies Interview Questions..-
If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.