AlgoViz

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 Quiz
64
34
25
12
22
11
90
45
Speed1x

Current 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

CaseTime Complexity
BestO(n²)
AverageO(n²)
WorstO(n²)
SpaceO(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