294.
function partition(a, left, right, pivotIndex)
pivotValue := a[pivotIndex]
swap(a[pivotIndex], a[right]) // 피벗을 끝으로 옮겨 놓는다.
storeIndex := left
for i from left to right-1
if a[i] = pivotValue then
swap(a[storeIndex], a[i])
storeIndex := storeIndex + 1
swap(a[right], a[storeIndex]) // 피벗을 두 리스트 사이에 위치시킨다.
return storeIndex
315.
function quicksort(a, left, right)
if right left then
select a pivot value a[pivotIndex]
pivotNewIndex := partition(a, left, right, pivotIndex)
quicksort(a, left, pivotNewIndex-1)
quicksort(a, pivotNewIndex+1, right)