1 answer

Using Python, reverse this insertion sort to sort from largest to smallest value. def insertionSort(alist): for...

Question:

Using Python, reverse this insertion sort to sort from largest to smallest value.

def insertionSort(alist):
for index in range(1,len(alist)):

currentvalue = alist[index]
position = index

while position>0 and alist[position-1]>currentvalue:
alist[position]=alist[position-1]
position = position-1

alist[position]=currentvalue


Answers

def insertionSort(alist):     for index in range(1, len(alist)):         currentvalue = alist[index]         position = index         while position > 0 and alist[position - 1] < currentvalue:             alist[position] = alist[position - 1]             position = position - 1             alist[position] = currentvalue   
.

Similar Solved Questions

2 answers
2. Design an idealized class B output stage, as shown in Figure 2, to deliver an...
2. Design an idealized class B output stage, as shown in Figure 2, to deliver an average of 25 W to an 82 speaker. The peak output voltage must be no larger than 80 percent of supply voltages Vcc. Determine: a) The required value of Voc b) The peak current in each transistor c) The power conversion ...
1 answer
Match the words in the left column to the appropriate blanks in the sentences on the...
Match the words in the left column to the appropriate blanks in the sentences on the right. Make certain each sentence is complete before submitting your answer. gains 1.Drag the beaker of water onto the support. The internal energy of water will be analyzed, which makes water the exothermic being s...
1 answer
Mr. Romero attached a ramp to the base of a window sill so that the family cat could more easily climb onto it. The ramp is 84 inches long. The window sill is 50 inches above the floor. ?
What is the distance from the base of the ramp to the base of the wall? Enter your answer, rounded to the nearest tenth, in the box....
1 answer
RCES Chapter 27, Problem 073 Wires A and B, having equal lengths of 41.1 m and...
RCES Chapter 27, Problem 073 Wires A and B, having equal lengths of 41.1 m and equal diameters of 2.80 mm, are connected in series. A potential difference of 60.8 V is applied between the ends of the composite wire. The resistances are RA = 0.113 2 and Rg = 0.646 2. For wire A, what are (a) magnitud...
1 answer
Please help with the following microeconomics question 3: 1. A city has a large number of...
Please help with the following microeconomics question 3: 1. A city has a large number of casinos. The demand by patrons for the games (in thousands per week) is Qd = 90 - 3P and the supply is Qs = 3P where P is the price charged to play a game. What is the equilibrium number (quantity) of games pla...
1 answer
Laser fume from plastics, metals and wood comprises harmful particulate matter. This industrial dust needs to...
Laser fume from plastics, metals and wood comprises harmful particulate matter. This industrial dust needs to be extracted from air when an operator is engaged in the laser cutting process. (i) Explain how both a cyclone and an electrostatic precipitator work, and then, giving your reasons, rational...
1 answer
Which of the following is NOT correct about randomization in clinical trials a.Randomization of subjects in...
Which of the following is NOT correct about randomization in clinical trials a.Randomization of subjects in a clinical trial helps to prevent some investigator-induced bias b.Randomization effectively removes placebo effects c.Randomization minimizes confounding by disrupting the association between...
1 answer
In the circuit below, each resistor has a resistance of R = 2.00Ω. What is the...
In the circuit below, each resistor has a resistance of R = 2.00Ω. What is the current, voltage drop, and power consumed in the resistor on the far right? Wh Hinrun 10.0V 5.00 V E = 1, P, V?...
1 answer
How does newton's third law apply to balloon cars?
How does newton's third law apply to balloon cars?...
1 answer
Instructions: Please read the following prompt and craft a response to all three questions. I want...
Instructions: Please read the following prompt and craft a response to all three questions. I want to see you follow the format in the guide a posted. You need facts, issues, authority (at least one primary and one secondary), analysis, and a conclusion. If you feel that you need more information to...
1 answer
Can i please get a detailed description of how to do this problem? i have asked...
can i please get a detailed description of how to do this problem? i have asked this same question multiple times and I still have no cule how to do it. please write on paper (hint: the answers are 331.30 N and 129.71 N Done Expert Q&A PLEASE WRITE ON PAPER NO TYPING the o m His c 10.0 m is ...
1 answer
Martin is a 38-year-old Mexican-American man who is a sergeant in the United States Army. He...
Martin is a 38-year-old Mexican-American man who is a sergeant in the United States Army. He recently returned from Iraq with a purple heart for leg wounds sustained during an enemy attack. Some of his patrol were killed. He is despondent over the prognosis that his injuries will prevent him from co...
1 answer
Question 1 - Carrying materials in inventory is expensive. Previous studies have found that the typical...
Question 1 - Carrying materials in inventory is expensive. Previous studies have found that the typical firm's annual inventory carrying cost is between 25 35% of the value of the inventory. Elaborate any Five (5) major elements the makes up these costs. [50 marks]...
1 answer
The supply of robotic welding machines is given by Qs= 5P-600. The government has levied a...
The supply of robotic welding machines is given by Qs= 5P-600. The government has levied a $154 per unit tax on the suppliers. Find the new supply function with the tax. Fill in the values below. OSTAX= 5P (Round to the nearest two decimal places if necessary. Remember to include a negative sign if ...
1 answer
Risk Factors for Low Birth Weight Rates of infant mortality, birth defect, and premature labor are...
Risk Factors for Low Birth Weight Rates of infant mortality, birth defect, and premature labor are high for babies with low birth weight. There are many factors that may contribute to low birth weight In this activity, we use data from a random sample of women who participated in a study in 1986 at ...