Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

Understand how emergent change occurs.

Answered: 1 week ago

Question

2. Enrolling employees in courses and programs.

Answered: 1 week ago

Question

1. Communicating courses and programs to employees.

Answered: 1 week ago