Actually Im wondering could you help solve the34questionsand
Solution
(1):
quicksort(A,s,pivot-1);
quicksort(A,pivot+1,e);
(2):
If you select first or last element of the range then the performance of quick sort algoritm is bad on partially sorted input.
If you select middle of the range then the performance of quick sort algoritm is better on partially sorted input.
However , selecting any random element runs the risk of badly partinioning the array of size m into 2 arrays of size 1 and m-1.
if you do that repeadly, then quicksort runs the risk of becoming O(n^2). So the performance of quicksort is highly depend on the selecting of good pivot.
(3)
idea:
One improvement I could think of is to pick median(first, last, mid). In the worst senario, it can still go to O(n^2), but probabilistically, this is a rare case. So, For most data, selecting the first and last element is sufficient but if you find that it not working fine and running into worst case scenarios often then the first option is to choose the central value. if you are still running into worst case then go to the median route.
