A quick short algorithm is based on the divide and conquer method. It divides the array in smaller parts and then shorts the array elements.
Pseudo code:
function partitionFunc(left, right, pivot)
leftPointer = left
rightPointer = right - 1
while True do
while A[++leftPointer] < pivot do
end while
while rightPointer > 0 && A[--rightPointer] > pivot do
end while
if leftPointer >= rightPointer
break
else
swap leftPointer,rightPointer
end if
end while
swap leftPointer,right
return leftPointer
end function
Comments
Leave a comment