Quicksort’s performance can be inefficient when the algorithm encounters imbalanced partitions. The worst case scenario is if the first or last element is always the partition point for an array or sub-array. In this case, one side of the partition will contain all the elements. This makes the recursive stack deeper, resulting in O(N^2)
runtime.
Quicksort is a method for sorting an array by repeatedly partitioning it into sub-arrays by:
The worst case runtime for quicksort is O(N^2)
and the average runtime for quicksort is O(N logN)
. The worst case runtime is so unusual that the quicksort algorithm is typically referred to as O(N logN)
“