ITPEC FE Subject A October 2024 Question 7
Which of the following is the appropriate description of the “selection sort” algorithm?
Explanation
Find the largest value, swap it to the end, repeat on the unsorted part — selection sort selects the extreme of the unsorted elements on each pass and puts it in its final place.
Each pass scans the unsorted part once to find its largest value, then makes a single swap to move it to the end of that part. After pass 1 the last position is final, after pass 2 the last two, and so on: n − 1 passes, about n2 ÷ 2 comparisons. Picking the smallest and moving it to the front is the same algorithm.
Answer (c)
Why not others:
- •(a) — choosing a reference value (pivot), splitting into larger and smaller groups and recursing is quicksort
- •(b) — sorting elements taken at a fixed interval and shrinking the interval down to 1 is Shell sort
- •(d) — repeatedly comparing and swapping adjacent elements is bubble sort, which may swap many times per pass where selection sort swaps once
Key rule: Match a sort to its signature move: selection picks the extreme, bubble swaps neighbours, insertion inserts into a sorted prefix, quicksort partitions around a pivot, Shell sort works on shrinking gaps.
Algorithm and Programming · AI-written, may contain errors
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.