Skip to main content

Quick Sort

Pass the array of numbers which needs to be sorted.

Usage

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

const arr = [2, 6, 3, 8];

const result = quickSort(arr)

Time Complexity

The time complexity of Quick Sort is:

CaseTime ComplexityDescription
BestO(nlogn)O(logn) decompositions and O(n) comparisons per decomposition
AverageO(nlogn)O(logn) decompositions and O(n) comparisons per decomposition
WorstO(n2)O(n) decompositions and O(n) comparisons per decomposition