What is the worst-case time complexity of the Quick Sort algorithm to sort a list of ‘n’ values?
What is the worst-case time complexity of the Quick Sort algorithm to sort a list of ‘n’ values? Correct Answer O(n<sup>2</sup>)
Concept:
Quicksort is an efficient sorting algorithm. It is also called partition-exchange sort which follows divide and conquer technique
Explanation
In quick sort worst case, the first or the last element is selected at the pivot element.
[ alt="F2 R.S Madhu 17.12.19 D1" src="//storage.googleapis.com/tb-img/production/19/12/F2_R.S_Madhu_17.12.19_D1.png" style="width: 285px; height: 275px;">
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
Therefore, worst-case time complexity of the Quicksort is O (n2)
মোঃ আরিফুল ইসলাম
Feb 20, 2025