Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

GATE | GATE-CS-2015 (Set 1) | Question 12

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Which one of the following is the recurrence equation for the worst case time complexity of the Quicksort algorithm for sorting n(≥ 2) numbers? In the recurrence equations given in the options below, c is a constant.

(A)

T(n) = 2T (n/2) + cn

(B)

T(n) = T(n – 1) + T(0) + cn

(C)

T(n) = 2T (n – 2) + cn

(D)

T(n) = T(n/2) + cn


Answer: (B)

Explanation:

In the worst case, the chosen pivot is always placed at a corner position and recursive call is made for the following:

a) For subarray on left of pivot which is of size n -1 in worst case.
b) For subarray on right of pivot which is of size 0 in worst case.


Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads