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

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:10, ashleybaber4966
If a particle moves along a path such that r : (3 sin t) m and ? : 2t rad, where t is in seconds. what is the particle's acceleration in m/s in 4 seconds? a)- 16.43 b)- 16.29 c)- 15.21 d)- 13.79
Answers: 1
image
Engineering, 04.07.2019 18:10, agpraga23ovv65c
Carbon dioxide gas expands isotherm a turbine from 1 mpa, 500 k at 200 kpa. assuming the ideal gas model and neglecting the kinetic and potential energies, determine the change in entropy, heat transfer and work for each kilogram of co2.
Answers: 2
image
Engineering, 04.07.2019 19:10, LadyHolmes67
Apressure vessel with an r/t 20 cannot be treated as thin walled vessel. a)-trune b)- false
Answers: 3
image
Engineering, 06.07.2019 03:10, cchotshot
Tom is having a problem with his washing machine. he notices that the machine vibrates violently at a frequency of 1500 rpm due to an unknown rotating unbalance. the machine is mounted on 4 springs each having a stiffness of 10 kn/m. tom wishes to add an undamped vibration absorber attached by a spring under the machine the machine working frequency ranges between 800 rpm to 2000 rpm and its total mass while loaded is assumed to be 80 kg. a) what should be the mass of the absorber added to the machine so that the natural frequency falls outside the working range? b) after a first trial of an absorber using a mass of 35 kg, the amplitude of the oscillation was found to be 10 cm. what is the value of the rotating unbalance? c) using me-3.5 kg. m, find the optimal absorber (by minimizing its mass). what would be the amplitude of the oscillation of the absorber?
Answers: 1
You know the right answer?
Create a bubble sort algorithm. this algorithm is capable of taking a list of numbers and placing th...

Questions in other subjects:

Konu
Mathematics, 21.09.2019 14:00