Programming Examples
Algorithm for Quick Sort
QuickSort(low,high)
1. If (low > high):
Return.
2. Set pivot = arr[low].
3. Set i = low + 1.
4. Set j = high.
5. Repeat step 6 until i > high or arr[i]> pivot.
// Search for an element greater than the pivot.
6. Increment i by 1.
7. Repeat step 8 until j < low or arr[j] < pivot. //Search for an element smaller than pivot
8. Decrement j by 1.
9. If i < j:
// If greater element is on the left of //smaller element
Swap arr[i] with arr[j].
10. If i <= j:
Go to step 5. // Continue the search
11. If low < j:
Swap arr[low] with arr[j]. //Swap pivot with last element in first part of //the list
Output