Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ PROGRAMMING Please make sure the code compiles and works so I can give you 5 stars :-) For this assignment, youll be creating a

C++ PROGRAMMING

Please make sure the code compiles and works so I can give you 5 stars :-)

For this assignment, youll be creating 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.

For your assignment, youll need to not only sort the given input (and display it in its final sorted form) but youll 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 its going to go.

So 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. Please sort the following three lists.

{1,3,7,5,2,4,6,8,9,10}

{10,9,8,7,6,5,4,3,2,1}

{1,10,2,9,3,8,4,7,5,6}

An example output might look like:

Sorted List: (1,2,3,4,5,6,7,8,9,10) 124 Actions Performed.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago