126k views
3 votes
Which of the following sorting algorithms is described by this text? "Take the item at index 1 and see if it is in order compared to the item at index 0. If it is not, then swap the two items. Next, take the item at index 2 and compare it to the items at the lower indexes. Move items in the lower indexes to a higher one until you find the proper location to place the value so that it is in the correct order. Continue this process with all remaining indexes."

a. insertion sort
b. selection sort
c. merge sort
d. quick sort
e. binary sort
An array of integers is to be sorted from smallest to biggest using a selection sort. Assume the array originally contains the following elements:
11 17 30 8 20 25
What will it look like after the third pass through the for loop?
a. 8 11 17 20 25 30
b. 8 11 17 30 20 25
c. 8 17 30 11 20 25
d. 8 11 17 20 30 25
e. 8 11 30 17 20 25

User Stevland
by
4.7k points

1 Answer

5 votes

Answer:

b. selection sort

b. 8 11 17 30 20 25

Step-by-step explanation:

The options above are the correct answers to the given questions.

Selection sort is a simple comparison-based sorting algorithm.

selection sort. (algorithm) Definition: A sort algorithm that repeatedly searches remaining items to find the least one and moves it to its final location. The run time is Θ(n²), where n is the number of elements. The number of swaps is O(n).

It is this sorting algorithm that will best ne suitable in the given event.

User Masyaf
by
5.4k points