As discussed in our video lecture, selection sort is a simple sorting algorithm that works by repeatedly
Fantastic news! We've Found the answer you've been seeking!
Question:
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:
Transcribed Image Text:
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 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
Expert Answer:
Related Book For
Numerical Methods for Engineers
ISBN: 9780071244299
5th Edition
Authors: Steven C. Chapra, Raymond P. Canale
Posted Date:
Students also viewed these programming questions
-
As discussed in our course, An infant must establish a feeling of mutuality with a caregiver in order to resolve their crisis. and mutuality is a central process to resolve the crisis facing by young...
-
The bubble sort is an inefficient, but easy-to-program, sorting technique. The idea behind the sort is to move down through an array comparing adjacent pairs and swapping the values if they are out...
-
A sorting algorithm is stable if elements with equal keys are left in the same order as they occur in the input. Which of the sorting algorithms in this chapter are stable and which are not? Why?
-
Climate-change concerns are resulting in investment in fuels that dont produce greenhouse gases. Although solar and wind power garner a lot of attention, nuclear power from uranium is also a...
-
Coffman Company sold bonds with a face value of $1,000,000 for $940,000. The bonds have a coupon rate of 10 percent, mature in 10 years, and pay interest semiannually every June 30 and December 31....
-
Keys 1, 2, . . . , 2k 1 are inserted in order into an initially empty AVL tree. Prove that the resulting tree is perfectly balanced.
-
Fraud deterrence is centered on the fear of getting caught and the fear of getting punished. In your opinion, which is stronger and why?
-
Capri Company began the current period with a $20,000 credit balance in the K. Capri, Capital account. At the end of the period, the companys adjusted account balances include the following temporary...
-
The number of admissions to all types of hospitals in a country between 1989 and 1996 can be described by the function A(t) = 35.283t2-1053.78t+40,539.967 thousand people where t is the number of...
-
You are an analyst at an asset management fund. The fund currently has five bonds in its portfolio with the attributes shown below. The funds founder believes that it is most likely that bond yields...
-
Juan recently took out a loan with an interest rate of 7.36%. The loan will require Juan to make monthly payments. What is the effective annual interest rate (EAR) of this loan?
-
How might you manage the balance between design and emergence strategizing processes in an organization?
-
A schedule in which activities have a firm, fixed order of completion is most likely: a. resource-constrained b. cost-constrained c. scope-constrained d. none of the above
-
Which of the four market structures would be most preferable to consumers? To organizations owners? To governments? Why?
-
The budget within the cost baseline that is allocated for identified risks, for which mitigating responses are developed, is called the _____________. a. contingency reserve b. management reserve c....
-
The amount of project budget reserved for unforeseen project work that addresses the unknown unknowns that can affect a project is the _____________. a. project buffer b. funding limit c. contingency...
-
The International Olympic Committee (IOC) rationed tickets to the London Olympics through a lottery. Do you think the IOC's policy of using a lottery is fair? Is it Pareto efficient?Explain why or...
-
Find the reduced echelon form of each of the matrices given in Problems 120. c 1 26 + 4
-
In water-resources engineering, the sizing or reservoirs depends on accurate estimates of water flow in the river that is being impounded. For some rivers, long-term historical records of such flow...
-
Repeat Example 14.2 for the following function at the point (0.8, 1.2). (x , y) = 2xy + 1.5y 1.25x 2 2y 2 + 5
-
Figure shows a circuit with a resistor, an inductor, and a capacitor in parallel. Kirchhoff?s rules can be used to express the impedance of the system as Where Z = impedance (?) and ? = the angular...
-
Scientists propose that the first macromolecules in protobionts were a. DNA molecules. b. RNA molecules. c. proteins. d. all of the above.
-
Which of the following function(s) is/are carried out by piRITS or piRISC? a. Inhibits transcription of TEs b. Causes the degradation of TE RNA c. Causes chromosome breakage d. Both a and b are...
-
In the CRISPR-Cas system, what does tracrRNA bind to? a. crRNA and Cas1 protein b. crRNA and Cas2 protein c. crRNA and Cas9 protein d. Cas1 and Cas2 proteins
Study smarter with the SolutionInn App