Selection Sort Visualizer
See Selection Sort scan for each minimum and place it into position with animated comparisons, swaps, controls, and metrics.
Comma-separated numbers, up to 20 values.
Live operation
compare
Comparisons
1
Moves / writes
0
Confirmed sorted
0 / 5
Algorithm notes
What to watch for
Selection Sort grows a sorted prefix from left to right. It spends comparisons finding the smallest remaining value, then performs at most one swap for each position.
Concept guide
Review the mental model, tradeoffs, and practical use cases after you experiment.
Selection Sort Complete Info Card
Selection Sort works by repeatedly selecting the smallest element from the unsorted portion and swapping it with the first unsorted element. It maintains two subarrays: sorted and unsorted.
Algorithm Characteristics
Time Complexity (Best)
Same as average case
Time Complexity (Average)
Regardless of input order
Time Complexity (Worst)
Same as average case
Space Complexity
In-place sorting algorithm
Stable
May change order of equal elements
Adaptive
Performance doesn't improve with nearly-sorted inputs
Sorting Process Steps
Find minimum element in unsorted portion
Swap with first unsorted position
Expand sorted portion by one element
Repeat until entire array is sorted
Performs exactly n-1 swaps total
Key Feature: Minimum Swaps
Selection Sort
Selection Sort makes exactly n-1 swaps always
Bubble Sort
Bubble Sort makes O(n²) swaps in worst case
Insertion Sort
Insertion Sort adapts to nearly-sorted data
When to Use
- •When swap operations are expensive
- •Small datasets or educational purposes
- •Memory-constrained environments
When to Avoid
- •Large datasets (use QuickSort/MergeSort)
- •When stability is required
- •Nearly-sorted data (use Insertion Sort)