AlgoScope

Selection Sort

AlgorithmbeginnerSorting

Scan for the smallest value left, then swap it home. At most n-1 swaps.

Decision · step 3 of 35Selection Sort: Seven values
50114223843576ijmin1 < 5

1 is smaller than 5: new minimum.

Open in the player →or start at step 3

What you will see

A scan finds the minimum (marked candidate), then one swap plants it at the boundary.

How selection sort works →

Cost

BestO(n^2)
AverageO(n^2)
WorstO(n^2)
SpaceO(1)

Always n(n-1)/2 comparisons; at most n-1 swaps.

Properties

  • ✓ comparison based
  • × stable
  • ✓ in place
  • × adaptive
  • × online

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next, compare two runs.

Screen readers: Cells announce index, value and state (comparing, swapped, sorted); each step announces the comparison outcome and any move.

Reduced motion: Swaps become value crossfades with outline flashes; sorted-region growth is a static span change.