- 2068 Magh · 3 marks
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.
| Pass | Smallest | Swap | List after the pass |
|---|---|---|---|
| Start | 33, 90, 45, 8, 52, 76, 5, 22 | ||
| 1 | 5 | 33 ↔ 5 | 5, 90, 45, 8, 52, 76, 33, 22 |
| 2 | 8 | 90 ↔ 8 | 5, 8, 45, 90, 52, 76, 33, 22 |
| 3 | 22 | 45 ↔ 22 | 5, 8, 22, 90, 52, 76, 33, 45 |
| 4 | 33 | 90 ↔ 33 | 5, 8, 22, 33, 52, 76, 90, 45 |
| 5 | 45 | 52 ↔ 45 | 5, 8, 22, 33, 45, 76, 90, 52 |
| 6 | 52 | 76 ↔ 52 | 5, 8, 22, 33, 45, 52, 90, 76 |
| 7 | 76 | 90 ↔ 76 | 5, 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)
Related questions
- Selection sort with trace · Data Structure and Algorithm, chapter 7
- Efficiency of straight selection sort · Data Structure and Algorithm, chapter 7
- Merge sort on 85, 76, 46, 92, ... · Data Structure and Algorithm, chapter 7
- Merge sort algorithm and trace · Data Structure and Algorithm, chapter 7
- Heap sort on 37, 33, 26, 92, ... · Data Structure and Algorithm, chapter 7
- Shell sort on 92, 83, 22, 49, ... · Data Structure and Algorithm, chapter 7
- Conductor selection, 100 MW 70 km 132 kV · Transmission and Distribution System Design, chapter 4
- Personnel management and selection steps · Construction Management, chapter 10 · asked 3×
- Total station features and data recording steps · Surveying II, chapter 9
- 22 pairs: means, consistency, correlation · Probability and Statistics, chapter 5