200k views
3 votes
One of the most studied computational problems is the ordering of a collection of values. Ordering is important because many problems set on collections of values become easy if the elements of the collection are ordered.

Sorting by selection is an example of sorting algorithm.

This algorithm consists of the following steps:

1. It is looked for in the part disordered by the smaller element and it is changed the smaller element with the element under the marker.

2. A marker is used to divide the ordered and disordered parts of the vector. The value 0 is assigned to the bookmark.

3. The marker is advanced.

4. The process repeats until there is only one element from the marker.

Check the alternative that shows the correct ordering of the steps of the sort ordering algorithm.

Alternatives:

The)
1 - 2 - 3 - 4.

B)
1 - 2 - 4 - 3.

w)
2 - 1-4.

(d)
2 - 1-3.

and)
2-3-1-4.

1 Answer

2 votes

I think the order should be 2-1-3-4, but the description of step 1 is confusing. In selection sort, you iterate from the point of the marker down through the entire list and find the smallest value, and swap that with the value at the marker. Then you advance the marker and repeat the process on the remainder of the list.

User Jon Nordby
by
6.0k points