Identify the number of swaps required for sorting the list 'num' using selection sort.
num=[63,42,21,9]
Identify the number of swaps required for sorting the list 'num' using selection sort.
num=[63,42,21,9]
Solution
✅ Correct Option: 2
Selection sort picks the smallest element in the unsorted part and swaps it into the next position. A swap is counted only when the minimum is not already in its place.
| Pass | Unsorted part | Minimum | Swap | List after pass |
|---|---|---|---|---|
| 1 | 63, 42, 21, 9 | 9 | 63 and 9 | 9, 42, 21, 63 |
| 2 | 42, 21, 63 | 21 | 42 and 21 | 9, 21, 42, 63 |
| 3 | 42, 63 | 42 | none, already in place | 9, 21, 42, 63 |
Total swaps
Option 1 (3): this counts one swap per pass for passes, but in pass 3 the minimum 42 is already in position, so no swap is needed.
Related questions:
2026: 29 May Shift 1
2025: 16 May Shift 1
2026: 18 May Shift 2