CPKit
v1.6.1

Selection Sort

SortingEasy

Select the minimum element from the unsorted zone and swap it to the front.

Alt+Shift+S

Configuration Panel

Scan / Min Swap Visualizer

23
0
8
1
56
2
12
3
38
4
5
5
72
6
16
7
Step: 1 / 1

Time Complexity

O(N^2) for all cases (always performs N^2 scans)

Space Complexity

O(1) auxiliary variables
Conceptual Overview

Selection Sort segments the list into sorted and unsorted zones, repeatedly finding the smallest element from the unsorted zone and swapping it into the next sorted position.

Algorithm Idea

Sweep the unsorted array to find the smallest element index. Swap it with the element at the boundary of the sorted and unsorted partitions.

Stable Sorting

Unstable (swaps can change original positions of equal elements)

In-place Memory

In-place (no auxiliary storage required)

Source: CP-Algorithms search & sorting reference