Quicksort

Quick sort is usually implemented recursively.

Algorithm
  Pick a "pivot point". {Picking a "good" pivot point can affect the running time, but don't ask me to explain.}   Break the list into two lists: those elements less than the pivot element, and those elements greater than the pivot element.   Recursively sort each of the smaller lists   Make one big list: the 'smallers' list, the pivot points, and the 'biggers' list  Here is the code Quicksort(A, low, high)

if (low < high)

pivot-location = Partition(A,low,high)

Quicksort(A,low, pivot-location - 1)

Quicksort(A, pivot-location+1, high)

Partition(A,low,high)

pivot = A[low]

leftwall = low

for i = low+1 to high

if (A[i] < pivot) then

leftwall = leftwall+1

swap(A[i],A[leftwall])

swap(A[low],A[leftwall])

return (leftwall)

