study / ordering / selection sort / test yourself / fresh numbers previous: insertion sort next: shell sort
fresh numbers The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from selection sort's own run on the numbers shown.
choose one 1 question 1Selection sort works on 4, 2, 6, 8, 7, 3. Its first pass swaps the 2 into place 1. What is the row after its third pass?
4 2 6 8 7 3
A 2, 3, 6, 8, 7, 4 B 2, 3, 4, 8, 7, 6 C 2, 3, 4, 6, 7, 8 D 2, 3, 4, 6, 8, 7 check my answer
the answer, and why the answer is B
Pass 1 gives 2, 4, 6, 8, 7, 3. Pass 2 gives 2, 3, 6, 8, 7, 4. Pass 3 swaps the 4 with the 6: 2, 3, 4, 8, 7, 6.
if you chose another
A That is the row after pass 2. C That is the row sorted, after every pass. D That shifts the numbers along to make room for the 4, as insertion sort would. Selection sort swaps the 4 with the 6. new numbers the test page's numbers
2 question 2How many comparisons does selection sort make on 1, 7, 5, 6, 2, 4, 3, from start to finish?
1 7 5 6 2 4 3
A 4 B 6 C 21 D 18 check my answer
the answer, and why the answer is C
The passes compare 11 + 4 + 3 + 2 numbers after their places, 21 in all.
if you chose another
A That counts the swaps. B That is one comparison per pass, but each pass compares every number after its place. D That is insertion sort's count on this row. new numbers the test page's numbers
3 question 3Selection sort works on each of these rows of 1 to 5. On which does it make the most swaps?
A 2, 1, 3, 4, 5 B 2, 1, 5, 3, 4 C 4, 3, 2, 1, 5 D 2, 1, 3, 5, 4 check my answer
the answer, and why the answer is B
Selection sort makes 3 swaps on 2, 1, 5, 3, 4, the most of the four.
if you chose another
A Selection sort makes 1 swap on this row, fewer than 3. C Selection sort makes 2 swaps on this row, fewer than 3. D Selection sort makes 2 swaps on this row, fewer than 3. new numbers the test page's numbers