← Back to Arrays
Selection Sort Visualization
Selection Sort finds the minimum element and places it at the beginning. It divides the array into sorted and unsorted portions, repeatedly selecting the smallest element.
Time Complexity
Best: O(n²)
Average: O(n²)
Worst: O(n²)
Space Complexity
O(1)
Comparisons
0
Swaps
0
0
300ms
Step 0 of 0 |Blue: Current MinimumYellow: ComparingRed: SwappingGreen: Sorted
How Selection Sort Works
- 1.Find the minimum element in the unsorted portion
- 2.Swap it with the first element of unsorted portion
- 3.Move the boundary between sorted and unsorted
- 4.Repeat until the entire array is sorted
Key Properties
- • Time Complexity: Always O(n²), regardless of input
- • Space Complexity: O(1) - sorts in place
- • Stability: Not stable (doesn't preserve relative order)
- • Adaptive: No - doesn't perform better on nearly sorted data
- • Swaps: At most n-1 swaps (fewer than bubble sort)