The performance of Quicksort depends on the choice of the pivot element in successive
passes. If we always happen to select the median of the elements as the pivot, then th e
partitioning process splits the array into two halves resulting in the O(n log n) best
performance of the sort . On the other hand, if in each pass we pick the largest or th e
smallest value as the pivot then the worst case performance of 0(n2) happens. However,
the efficiency of Quicksort is due to the fact that its average performance is also 0(n log n) .