Question: The selection sort algorithm is def selectionSort(aList): for fillslot in range(len(aList)-1,0,-1): positionOfMax=0 for location in range(1,fillslot+1): if aList[location]>aList[positionOfMax]: positionOfMax = location # swap largest element

The selection sort algorithm is

def selectionSort(aList): for fillslot in range(len(aList)-1,0,-1): positionOfMax=0 for location in range(1,fillslot+1): if aList[location]>aList[positionOfMax]: positionOfMax = location # swap largest element in correct place temp = aList[fillslot] aList[fillslot] = aList[positionOfMax] aList[positionOfMax] = temp

The selection sort algorithm is def selectionSort(aList): for fillslot in range(len(aList)-1,0,-1): positionOfMax=0

Q3 Selection Sort 20 Points The textbook goes through the implementation of the Selection Sort algorithm. Use the implementation in the textbook to answer the following subquestions. Q3.1 10 Points Assume we pass the following list into the Selection Sort function: [1, 10, 3, 7, 9, 5] Write the state of the list (as if it were in a print function) at the end of the iteration where fillslot = 4. I would try and work through this algorithm by hand first. You can always double-check your answer by writing this algorithm and running it. Note that this question will be autograded, so please be EXACT with your answer (same spacing, brackets, commas, etc) as you would see in printing a list to the interactive shell (such as [X, Y, Z]). Enter your answer here Save Answer Q3.2 10 Points Assume we pass the following list into the Selection Sort function: [1, 10, 3, 7, 9, 5] Write the state of the list (as if it were in a print function) at the end of the iteration where fillslot = 2 I would try and work through this algorithm by hand first. You can always double-check your answer by writing this algorithm and running it. Note that this question will be autograded, so please be EXACT with your answer (same spacing, brackets, commas, etc) as you would see in printing a list to the interactive shell (such as [X, Y, z]). Enter your answer here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!