Skip to main content

Straight selection sort on 33, 90, 45, ...

Short answer

Straight selection sort repeatedly finds the smallest unsorted element and swaps it into place. After 7 passes, the sorted list is 5, 8, 22, 33, 45, 52, 76, 90.

Trace the sorting steps in straight selection sort for the data: 33, 90, 45, 8, 52, 76, 5, 22.

In each pass, find the smallest element in the unsorted part and swap it with the first element of that part.

PassSmallestSwapList after the pass
Start33, 90, 45, 8, 52, 76, 5, 22
1533 ↔ 55, 90, 45, 8, 52, 76, 33, 22
2890 ↔ 85, 8, 45, 90, 52, 76, 33, 22
32245 ↔ 225, 8, 22, 90, 52, 76, 33, 45
43390 ↔ 335, 8, 22, 33, 52, 76, 90, 45
54552 ↔ 455, 8, 22, 33, 45, 76, 90, 52
65276 ↔ 525, 8, 22, 33, 45, 52, 90, 76
77690 ↔ 765, 8, 22, 33, 45, 52, 76, 90

Answer: 5, 8, 22, 33, 45, 52, 76, 90 (7 passes for 8 elements)

✓ Answer checked by Claude Opus 5.5 (high effort)

All Data Structure and Algorithm chapter 7 questions →