QuickSort(A,p,r)if p < r // Partition the subarray around the pivot, which ends up in A[q]. q = Partiton(A,p,r) QuickSort(A,p,q-1) //recursively sort the short side QuickSort(A,q+1,r) //recursively sort the high side
Partition
A[p:r]
Partition(A,p,r)pivot = A[r] //the pivoti = p - 1 //highest index into the low sidefor j = p to r - 1 if A[j] <= pivot i = i + 1 exchange A[i] with A[j]exchange A[i+1] with A[r]return i + 1