Skip to main content

Selection Sort

Repeatedly finds the minimum element from the unsorted portion and places it at the beginning.

Interactive Visualization

Loading visualization…

Usage

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

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

Time Complexity

CaseTime ComplexityDescription
BestO(n²)Always scans the unsorted region
AverageO(n²)Linear scan for each position
WorstO(n²)Same number of comparisons regardless of input