Sorting visualizer

Selection Sort

Select the smallest remaining value for each position.

Example Array
[42, 17, 8, 33, 25, 11, 60, 29]

Visualization

Ready
ComparingMoving / writingPivotSorted

Selection Sort is ready to find the smallest value.

Metrics

Comparisons0
Swaps0
Progress0%
Time taken0.0s

Pseudocode

  1. for i from 0 to n - 2
  2. minIndex = i
  3. for j from i + 1 to n - 1
  4. if arr[j] < arr[minIndex]
  5. minIndex = j
  6. swap arr[i] and arr[minIndex]
  7. return arr

About Selection Sort

Selection Sort scans the unsorted section to find its minimum value, then places that value at the next position in the sorted section.

Sorted Output

[ 8, 11, 17, 25, 29, 33, 42, 60 ]

Complete the visualization to reach this output.

Complexity Overview

Best CaseO(n²)
Average CaseO(n²)
Worst CaseO(n²)
SpaceO(1)
StableNo