Skip to main content

Quick Sort

Selects a pivot element, partitions the array around it, and recursively sorts the subarrays.

Interactive Visualization

Loading visualization…

Usage

src/sample/quicksort.ts
import { quickSort } from 'athro';

const arr = [2, 6, 3, 8];
const result = quickSort(arr);

Time Complexity

CaseTime ComplexityDescription
BestO(n log n)Balanced partitions
AverageO(n log n)Typical pivot behavior
WorstO(n²)Already sorted input with poor pivot choice