Exams › GATE › Technical
Consider the Quicksort algorithm. Suppose there is a procedure for finding a pivot element which splits the list into two sub-lists each of which contains at least one-fifth of the elements. Let T(n) be the number of comparisons required to sort n elements. Then
- T(n) ≤ 2T(n/5) + n
- T(n) ≤ T(n/5) + T(4n/5) + n
- T(n) ≤ 2T(4n/5) + n
- T(n) ≤ 2T(n/2) + n
Correct answer: T(n) ≤ T(n/5) + T(4n/5) + n
Solution
The correct option reflects the recursive nature of the Quicksort algorithm, where the list is divided into two parts: one containing at least one-fifth of the elements and the other containing the remaining elements. This ensures that the total number of comparisons includes the work done on both sub-lists, plus the linear time needed for partitioning.
Related GATE Technical questions
⚔️ Practice GATE Technical free + battle 1v1 →