Sort the following array a using quicksort,
[6, 11, 4, 9, 8, 2, 5, 8, 13, 7]
The pivot should be chosen as the arithmetic mean of the first
Your pivot is 6. Your pivot is NOT the 6th element Now you can apply the following algorith.
function quicksort(array)
var list less, greater
if length(array) ≤ 1
return array // an array of zero or one elements is already sorted
select and remove a pivot value pivot from array
for each x in array
if x ≤ pivot then append x to less
else append x to greater
return concatenate(quicksort(less), pivot, quicksort(greater))