When does the quicksort algorithm take O(n^2) time?
The factors that contribute to the worst-case scenario of quicksort are as follows:
n-1
elements in the other.In other words, the worst-case running time of quicksort occurs when Quicksort takes in a sorted array (in decreasing order), to be on the time complexity of O(n^2).