Selection sort

Selection sort · O(n²)

Elements Active CompletePlayed 0.0 s · same input

Selection sort

Selection sort
O(n²)
Operations0
Comparisons0
Writes0

Each comparison or write counts as 1 operation. Playback time is not execution time.

← Back to six-algorithm comparison
How it works +

Pick the minimum from the unsorted portion and move it to the front. Many comparisons, few swaps: like repeatedly picking the thinnest book from a pile.

Extra space: O(1); Unstable. Each comparison or main-array write counts as 1 operation.