What does the array look like after two passes of selection sort in ascending order?
Correct answer A. [10, 13, 14, 37, 29]
Explanation
Each pass finds the minimum of the unsorted part and swaps it into the next position. Pass 1 swaps 10 with 29, giving [10, 29, 14, 37, 13]. Pass 2 finds 13 as the smallest of the rest and swaps it with 29, giving [10, 13, 14, 37, 29]. Selection sort always makes exactly n − 1 passes and O(n²) comparisons.
Answer checked How we write and check questions
Discussion