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
For the given array [6, 11, 4, 9, 8, 2, 5, 8, 13, 7]
Calculate something like this:
6
Select last element of list which is 7
Select mid element which is mid = (length%2==0) ? (length/2)-1 : (length-1)/2
, which is 8
[6,7,8]
, now mid element in your array is mid.