Question:

Consider the quicksort algorithm. Suppose there is a procedure for finding a pivot element which splits the list into two sub-lists, one of which contains one-fifth of the elements and the remaining elements are contained in the other sub-list. Let T(n) be the number of comparisons required to sort n elements. Then:

Show Hint

In recurrence relations, always include the partitioning cost (e.g., n) along with recursive calls for sub-problems.
Updated On: Dec 29, 2024
  • 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
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

In quicksort, the time complexity is determined by the partitioning strategy: - Here, the pivot splits the list into two parts: n/5 and 4n/5. - The recurrence relation becomes: T(n) = T(n/5) + T(4n/5) + n. - The n term accounts for the partitioning step, where comparisons are made for all n elements.
Was this answer helpful?
0
0

Top Questions on Algorithm

View More Questions

Questions Asked in CUET PG exam

View More Questions