I'm a physicist, please excuse my ignorance :(
Does the pivot have to be an array element? If so, why? Does choosing an array element as pivot offer any considerable advantage?
I ask this because choosing the average of the array elements seems like it would be fairly robust (avoid cases where the subarrays are 1 and N-1 long etc). The average might not be an array element (eg: it could be a float for an array of integers)
Thanks!