Answered step by step
Verified Expert Solution
Question
1 Approved Answer
As discussed in our video lecture, selection sort is a simple sorting algorithm that works by repeatedly finding the minimum element from unsorted part and
As discussed in our video lecture, selection sort is a simple sorting algorithm that works by repeatedly finding the minimum element from unsorted part and putting it the sorted portion of
Starter Code:
Goal: [10 pts] As discussed in our video lecture, selection sort is a simple sorting algorithm that works by repeatedly finding the minimum element from unsorted part and putting it the sorted portion of the list, so in every pass of selection sort, we put the minimum element from the unsorted subarray in the proper place in the sorted portion of the list. Write the function selectionSort(numList) that takes an unsorted list of numbers and uses the selection sort algorithm to return the sorted list. The function also returns a dictionary with the state of the list after each complete pass. - You are not allowed to use the sorted() method or the sort operator. Your code will not get credit if you use them - You are not allowed to use the min() or max() built-in methods Function returns 2 values: return dictionary, sorted list (there is no need to add parentheses) Method should mutate the original list >>> x= [9,3,5,4,1, 67, 78] >>> selectionSort (x) ({1: [9, 3, 5, 4, 1, 67, 78], 2: [1, 3, 5, 4, 9, 67, 781, 3: [1, 3, 5, 4, 9, 67, 78], 4: [1, 3, 4, 5, 9, 67, 78], 5: [1, 3, 4, 5, 9, 67, 78], 6: [1, 3, 4, 5, 9, 67, 78], 7: [1, 3, 4, 5, 9, 67, 78]), [1, 3, 4, 5, 9, 67, 781) >>> X [1, 3, 4, 5, 9, 67, 78] Second returned value, the sorted list def selectionSort (numList): 111 Takes a list and returns 2 values 1st returned value: a dictionary with the state of the list after each complete pass of selection sort 2nd returned value: the sorted list >>> selectionSort ( [9, 3, 5, 4, 1, 78,67]) ({1: [9, 3, 5, 4, 1, 78, 67], 2: [1, 3, 5, 4, 9, 78, 67], 3: [1, 3, 5, 4, 9, 78, 67], 4: [1, 3, 4, 5, 9, 78, 67], 5: [1, 3, 4, 5, 9, 78, 67], 6: [1, 3, 4, 5, 9, 78, 67], 7: [1, 3, 4, 5, 9, 67, 78]), [1, 3, 4, 5, 9, 67, 78]) # YOUR CODE STARTS HERE
Step by Step Solution
★★★★★
3.38 Rating (142 Votes )
There are 3 Steps involved in it
Step: 1
Solution def selectionSortn...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started