Here is the implementation of quicksort:
function quickSort(arr, low, high):
if low < high:
pivotIdx = partition(arr, low, high)
quickSort(arr, low, pivotIdx - 1)
quickSort(arr, pivotIdx + 1, high)
Time: average. worst case (already sorted with bad pivot choice).
Space: average for recursion stack. worst case.
Stability: Unstable. Partitioning swaps elements across the pivot.
Optimization: Use randomized pivot or median-of-three to avoid on sorted input. Most library implementations use introsort: quicksort that switches to heapsort if recursion gets too deep.