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

This question was previously asked in

GATE CS 2015 Official Paper: Shift 1

- T(𝑛) = 2 T(𝑛/2) + 𝑐n
- T(𝑛) = T(𝑛 – 1) + T(1) + 𝑐n
- T(𝑛) = 2T(𝑛 – 1) + 𝑐n
- T(𝑛) = T(𝑛/2) + 𝑐n

Option 2 : T(𝑛) = T(𝑛 – 1) + T(1) + 𝑐n

Free

IBPS SO IT Officer Mains: Full Mock Test

5486

60 Questions
60 Marks
45 Mins

Worst-case time complexity of the Quicksort is O (n2)

In quick sort worst case, the first or the last element is selected at the pivot element.

For a quicksort, in worst case recurrence relation will become T(n) = T(n-1) + T (1) + n

Recurrence relation gives: T(n) = O (n2). Hence option 2 is correct

India’s **#1 Learning** Platform

Start Complete Exam Preparation

Daily Live MasterClasses

Practice Question Bank

Mock Tests & Quizzes

Trusted by 2,30,54,625+ Students

Start your FREE coaching now >>

Testbook Edu Solutions Pvt. Ltd.

1st & 2nd Floor, Zion Building,

Plot No. 273, Sector 10, Kharghar,

Navi Mumbai - 410210

[email protected]
Plot No. 273, Sector 10, Kharghar,

Navi Mumbai - 410210

Toll Free:1800 833 0800

Office Hours: 10 AM to 7 PM (all 7 days)