Skip to main content

Selection Sort

Pass the array of numbers which needs to be sorted.

Usage

src/sample/selectionsort.ts
import { selectionSort } from 'athro';

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

const result = selectionSort(arr)

Time Complexity

The time complexity of Selection Sort is:

CaseTime ComplexityDescription
BestO(n2)n comparisons for n items
AverageO(n2)n comparisons for n items
WorstO(n2)n comparisons for n items