224k views
1 vote
) Which of the following lists of numbers would accurately show the array after the first pass through the Selection

Sort algorithm?
a) 9, 4, 12, 2, 6, 8, 18
b) 4, 9, 12, 2, 6, 8, 18
c) 2, 4, 12, 9, 6, 8, 18
d) 2, 4, 6, 8, 9, 12, 18
e) 2, 4, 9, 12, 6, 8, 18

1 Answer

4 votes

Answer:

c) 2, 4, 12, 9, 6, 8, 18

Explanation:

The given list of numbers given in the array is: 9, 4, 12, 2, 6, 8, 18

We start selection sort by scanning the entire given list to find its smallest element and exchange it with the first element, putting the smallest element in its final position in the sorted list. Then we scan the list, starting with the second element, to find the smallest among the last n − 1 elements and exchange it with the second element, putting the second smallest element in its final position.

During the first pass, 2 is the smallest element, it will be moved to index 0 and 9 which was in index 0 will replaced 2 in it initial position.

User Myuce
by
5.1k points