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, 03.07.2019 14:10
Line joining liquid phase with liquid and solid phase mixture is known as: a) liquidus b) solidus c) tie line d) none of the mentioned
Answers: 2
question
Engineering, 04.07.2019 18:10
Adouble-strand no. 60 roller chain is used to transmit power between a 13-tooth driving sprocket rotating at 300 rev/min and a 52-tooth driven sprocket. a) what is the allowable horsepower of this drive? b) estimate the center-to-center distance if the chain length is 82 pitches. c) estimate the torque and bending force on the driving shaft by the chain if the actual horsepower transmitted is 30 percent less than the corrected (allowable) power.
Answers: 3
question
Engineering, 04.07.2019 18:10
The drive force for diffusion is 7 fick's first law can be used to solve the non-steady state diffusion. a)-true b)-false
Answers: 1
question
Engineering, 04.07.2019 18:10
Which one from below is not one of the reasons of planning failures? (clo3) a)-planner is careless. b-planner spend less time in the field but more time on the desk c)-planner is not qualified d)-planner does not have sufficient time to properly plan
Answers: 3
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, 21.06.2021 17:30
question
Mathematics, 21.06.2021 17:30
question
Mathematics, 21.06.2021 17:30
question
Mathematics, 21.06.2021 17:30
Questions on the website: 13722360