Which one of the following is the recurrence equation for the worst case time complexity of the quick sort algorithm for sorting numbers? In the recurrence equations given in the options below, is a constant.
View worked solution
Answer: B
The worst-case time complexity of the Quicksort algorithm occurs when the pivot element consistently partitions the array into highly unbalanced subproblems. This typically happens when the array is already sorted (or reverse-sorted) and the first or last element is chosen as the pivot.
In this worst-case scenario:
- The array of size is partitioned into one subproblem of size and another of size .
- The partitioning step itself takes linear time, represented as (where is a constant).
Thus, the recurrence relation representing this behavior is:
Solving this recurrence yields the worst-case time complexity of .
Elimination of other options:
- Option A: represents the best-case (or average-case) recurrence of Quicksort, where the pivot always divides the array into two equal halves, yielding complexity.
- Option C: would result in an exponential time complexity , which is incorrect.
- Option D: represents a binary-search-like reduction with linear work, yielding complexity.
Free practice · Your answers on this page are not saved.
