The list of numbers 4, 9, 8, 1, 6
is to be sorted using the selection sort algorithm.
Enter the output after each line of the selection sort algorithm.
Step Number | Algorithm Step | OUTPUT |
---|---|---|
$1$1 | Find the smallest number. Swap it with the first number. |
$\editable{},\editable{},\editable{},\editable{},\editable{}$,,,, |
$2$2 | Find the second-smallest number. Swap it with the second number. |
$\editable{},\editable{},\editable{},\editable{},\editable{}$,,,, |
$3$3 | Find the third-smallest number. Swap it with the third number. |
$\editable{},\editable{},\editable{},\editable{},\editable{}$,,,, |
$4$4 | Find the fourth-smallest number. Swap it with the fourth number. |
$\editable{},\editable{},\editable{},\editable{},\editable{}$,,,, |
A bug is an error in the algorithm which results in the algorithm not producing the desired output.
The algorithm below contains a bug. What is the output of each line of the algorithm?
Step Number | Algorithm Step | OUTPUT |
---|---|---|
$1$1 | Find the smallest number. Swap it with the first number. |
$\editable{},\editable{},\editable{},\editable{},\editable{}$,,,, |
$2$2 | Find the second-smallest number. Swap it with the first number. |
$\editable{},\editable{},\editable{},\editable{},\editable{}$,,,, |
$3$3 | Find the third-smallest number. Swap it with the third number. |
$\editable{},\editable{},\editable{},\editable{},\editable{}$,,,, |
$4$4 | Find the fourth-smallest number. Swap it with the fourth number. |
$\editable{},\editable{},\editable{},\editable{},\editable{}$,,,, |
Which step contains the bug?
Step 1
Step 3
Step 4
Step 2
The list of numbers 5, 9, 7, 1, 6
is to be sorted using the selection sort algorithm.
The list of numbers 4, 9, 8, 1, 7
is to be sorted using the insertion sort algorithm.
The list of numbers 3, 8, 5, 2, 4
is to be sorted using the insertion sort algorithm.