Selection Sort
Selection Sort divides the array into sorted and unsorted parts, repeatedly selecting the minimum element from the unsorted part.
BeginnerTime: O(n²)Space: O(1)
Take QuizCurrent Step
Press Play to start the visualization
## How Selection Sort Works
Selection Sort divides the array into a sorted and unsorted region. It repeatedly finds the minimum element from the unsorted region and moves it to the sorted region.
### Algorithm Steps:
1. Find the minimum element in the unsorted portion
2. Swap it with the first unsorted element
3. Move the boundary between sorted and unsorted one element right
4. Repeat until the entire array is sorted
### Key Characteristics:
- **In-place**: Only requires O(1) extra space
- **Not Stable**: May change relative order of equal elements
- **Simple**: Easy to understand and implement
Time & Space Complexity
| Case | Time Complexity |
|---|---|
| Best | O(n²) |
| Average | O(n²) |
| Worst | O(n²) |
| Space | O(1) |
Practice Problems
10 problems81 total points
1
Basic Selection Sort
Beginner5 pts
2
Find Maximum
Beginner5 pts
3
Sort by Second Element
Beginner5 pts
4
Stable Selection Sort
Intermediate8 pts
5
Min-Max Selection Sort
Intermediate8 pts
6
Heap Selection
Advanced10 pts
7
K Smallest Elements
Advanced10 pts
8
Bingo Sort
Advanced10 pts
9
Pancake Sort
Advanced10 pts
10
Sort with Min Comparisons
Advanced10 pts