Solution Found!
Simulate the execution of algorithm SelectionSort on the following list L; write the
Chapter 3, Problem 84(choose chapter or problem)
Simulate the execution of algorithm SelectionSort on the following list L; write the list after every exchange that changes the list. 9, 0, 2, 6, 4
Questions & Answers
QUESTION:
Simulate the execution of algorithm SelectionSort on the following list L; write the list after every exchange that changes the list. 9, 0, 2, 6, 4
ANSWER:Step 1 of 2
In selection sort algorithm, the list is divided into two parts, the sorted part at the left end and the unsorted part at the right end. Initially, the sorted part is empty and the unsorted part is the entire list.
The recursive algorithm is given below.
SelectionSort (list ; positive integer)
//recursively sorts the items from 1 to in list into increasing order
if then
sort is complete, write out the sorted list
else
find the index of the maximum item in between 1 and
exchange and
SelectionSort()
end if
end function SelectionSort