Selection Sort
Finds the minimum element in the unsorted region and swaps it into the next sorted position.
0 elements
>Ready — Selection Sort
Code
1
2
3
4
5
6
7
8
9
10
11
Analysis
BEST O(n²)
AVG O(n²)
WORST O(n²)
SPACE O(1)
Selection Sort divides the array into sorted and unsorted regions. Each pass scans the unsorted region for the smallest element, then swaps it into the next sorted position. Always makes O(n²) comparisons regardless of input order.