In-place partition-based divide & conquer sorting algorithm. Average case O(n log n) with tiny constants, dominating practical workloads. Worst-case O(n^2) occurs only under systematically bad pivot choices. Randomization or median-of-three heuristics make such degeneracy extremely unlikely.
Partition scanning walks the segment once, expanding a prefix of elements less than or equal to the pivot. Each qualifying element is swapped into the growing prefix. Finally the pivot is swapped into the boundary slot producing two subproblems with the pivot fixed.
Average / Randomized: T(n) ≈ 2T(n/2) + O(n) → O(n log n).
Worst: T(n) = T(n-1) + O(n) → O(n^2) (pathological pivot chain).
Tail recursion: last call often optimized / manually looped to reduce stack.