This is such a beautifully formed question.
The question says ""Quick sort gives $O\left ( nlogn \right )$ in worst case" .
The worst case of quick sort occurs when the array is sorted and one of the extreme elements is chosen as pivot.
Since, the question mentions worst case, we need to consider the case of sorted input.
Now lets analyze the options:
a) First element: This is clearly out of the game as this will give time complexity of $O\left( n^{2} \right )$.
c)Arithmetic mean: This number depends upon the distribution of numbers.If the numbers are uniformly distributed in an interval, then the arithmetic mean would probably lie near the centre of the array.But this may not be the case always.Hence,this option is also rejected.
b)Median of 1st, last and middle element:If the input is sorted, then the median of these three elements will be the middle element itself.Also, in sorted array, the middle element is median itself.
So in any case, the median will give a half-half partitioning when we consider the worst case.
This half-half partitioning will lead to $O\left ( nlogn \right )$ in worst case.
Important point: The median of entire input may require $O\left(n\right)$ time.But here we only need to find median of those 3 elements and that too when the array is sorted which will take constant time.
Therefore, option B seems best choice.
- Happy Learning