Quicksort

Computer Science

How It Works

Quicksort is an efficient, divide-and-conquer in-place array sorting algorithm. The algorithm isolates a pivot element and partitions adjacent values into dual sub-arrays according to whether they are smaller or greater than the pivot. Recursively repeating this partitioning protocol across divided sub-arrays achieves an optimal average-case runtime complexity of O(n log n) with negligible auxiliary memory overhead.

Governing Equation
$$ T(n) = 2T(n / 2) + \mathcal{O}(n) \implies T(n) = \mathcal{O}(n \log n) \quad\vert\quad T_{\text{worst}}(n) = \mathcal{O}(n^2) $$