# GATE | GATE-CS-2014-(Set-3) | Question 24

• Last Updated : 10 Nov, 2017

You have an array of n elements. Suppose you implement quicksort by always choosing the central element of the array as the pivot. Then the tightest upper bound for the worst case performance is
(A) O(n2)
(B) O(nLogn)
(C) Theta(nLogn)
(D) O(n3)

Explanation: For any input, there are some permutations for which worst case will be O(n2).  In some case, choosing the middle element minimizes the chances of encountering O(n2), but in worst case it can go to O(n2). Whichever element we take as Pivot, either first or middle, worst case will be O(n2since Pivot is fixed in position. While choosing a random pivot minimizes the chances of encountering worst case i.e. O(n2).

Refer this article on Quick Sort.

Quiz of this Question

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up