Skip to main content

Quick Sort Algorithm (under Hoare's method)

*
QuickSort(Array[],low,high) is if low < high then p := PartitionPoint(Array, low, high); quicksort(Array, low, p); quicksort(Array, p + 1, high); PartitionPoint(Array[], low, high) is pivot := A[(low + high) / 2] i := low - 1; j := high + 1; while(true) //loop forever do i++; while A[i] < pivot //started comparing from left side of array do j--; while Array[j] > pivot //started comparing from right side of array if i >= j then return j; else swap A[i] with A[j]

Quote:

Go as far as you can see; when you get there,you'll be able to see farther...