subject
Engineering, 18.11.2019 22:31 jjoyner

Create a bubble sort algorithm. this algorithm is capable of taking a list of numbers and placing them in order, however it is also known as one of the least efficient means of doing so. functionally, a bubble sort will proceed from left to right through an array, comparing pairs on its way. if the first half of the pair it's looking at is larger than the second half of the pair, it will swap them, then continue to the next pair. it will then repeat this process several times over until the list is fully sorted. view the example below: you'll notice the underlined numbers as we go. once the bubble sort visits the last sorted element in an array, it doesn't have to bother with that element anymore, because it's already where it will be in the final sorted array. this can be accomplished in a simple code by keeping track of where the final sorted variable is located with just a simple integer. for this assignment, you'll need to not only sort the given input (and display it in its final sorted form) but you'll also need to keep track of how many comparisons, and reassignments happen. so comparing two numbers will be counted as a single action. swapping the location of two variables will meanwhile be considered three actions, one to store a variable to be swapped in a temporary storage location, another to swap the first of the variables to the second location, and a third to move the variable from the temporary storage location back to where it's going to go. to summarize, comparing two objects in the array will count as one action, and swapping two objects in the array will count as three actions. your results should not only display the sorted version of the array, but also a count of the total number of actions that took place while sorting. sort the following two lists.{1,2,3,4,5,6,7,8,9,10}{10,9,8 ,7,6,5,4,3,2,1}

ansver
Answers: 3

Another question on Engineering

question
Engineering, 04.07.2019 18:10
The higher the astm grain-size number, the coarser the grain is. a)-true b)-false
Answers: 3
question
Engineering, 04.07.2019 18:10
Condition monitoring is a major component of. (clo4) a)- predictive maintenance. b)-preventive maintenance c)-proactive maintenance d)-reactive maintenance.
Answers: 1
question
Engineering, 04.07.2019 18:10
Compute the pressure drop of 30°c air flowing with a mean velocity of 8 m/s in a circular sheet-metal duct 300 mm in diameter and 15 m long. use a friction factor, f 0.02, and pair = 1.1644 kg/m a. 37.26 pa b. 25.27 pa n c. 29.34 pa d. 30.52 pa
Answers: 1
question
Engineering, 04.07.2019 18:20
Apiston-cylinder device contains 0.1 m3 of liquid water and 0.9 m3 of water vapor in equilibrium at 800 kpa. heat is transferred at constant pressure until the temperature of water reaches 350 °c. determine (a) the quality of water at the initial state (b) the work associated with this process, (c) the heat associated with this process.
Answers: 2
You know the right answer?
Create a bubble sort algorithm. this algorithm is capable of taking a list of numbers and placing th...
Questions
question
Mathematics, 18.08.2019 21:30
question
Mathematics, 18.08.2019 21:30
question
Geography, 18.08.2019 21:30
Questions on the website: 13722361