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
| Case | Time Complexity | Description |
|---|---|---|
| Best | O(n²) | Always scans the unsorted region |
| Average | O(n²) | Linear scan for each position |
| Worst | O(n²) | Same number of comparisons regardless of input |