Selection Sort

Selects the smallest remaining element and places it into the next position.

Stable:NoIn-place:Yes
Complexity
Best
O(n²)
Average
O(n²)
Worst
O(n²)
Space
O(1)
When to use: Mostly educational; useful when minimizing swaps matters.Very simpleSlow on large inputs (O(n²) comparisons)
Pseudocode
for i from 0 to n-1
min = i; for j from i+1 to n-1
if a[j] < a[min]
min = j
swap a[i], a[min]
mark i as sorted
done
Waiting to start…