Open In App

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

Like Article
Like
Save
Share
Report

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


Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads