State after two passes
Warm-up · Trace the algorithm · about 4 min
Selection sort runs on [29, 10, 14, 37, 13]. Arrange the values as they stand after the first two passes.
Example 1
Input:
{"values":[29,10,14,37,13]}
Output:
[10,13,14,37,29]
Constraints
- The trace uses the input shown.
- Each pass makes at most one swap.
Learn the idea first: Selection sort, a visual lesson.
More Selection sort problems
- Count comparisons Warm-up
- Is selection sort stable? Standard
- Implement selection sort Standard
- The k smallest values Standard
- Selection sort of pairs by key Challenge