Intermediate 25 min

Interactive Visualization

Watch selection sort work in real-time. The visualizer shows each selection and swap.

Selection Sort Visualization

1x

What to Observe

As you watch the visualization, notice:

  1. Selection: Minimum element is highlighted
  2. Comparison: Elements are compared to find minimum
  3. Swap: Minimum is swapped to correct position
  4. Sorted portion: Grows from left to right
  5. Unsorted portion: Shrinks with each pass

Understanding the Colors

  • Green: Elements in sorted portion
  • Red/Orange: Current minimum being selected
  • Blue: Elements being compared
  • Default: Unsorted elements

Try Different Arrays

The visualizer starts with [10, 50, 30, 20, 40]. Notice how:

  • Each pass finds the minimum
  • Only one swap per pass
  • Sorted portion grows systematically

What’s Next?

Now that you’ve seen it work, let’s implement selection sort in code.