Simulate the execution of algorithm SelectionSort on the following list L; write the

Chapter 3, Problem 84

(choose chapter or problem)

Get Unlimited 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

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

Add to cart


Study Tools You Might Need

Not The Solution You Need? Search for Your Answer Here:

×

Login

Login or Sign up for access to all of our study tools and educational content!

Forgot password?
Register Now

×

Register

Sign up for access to all content on our site!

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back