Practice mode Data Structures

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.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.