Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ Please! Lab&A: For this part of the lab, refer to the lecture slides for a review of Bubble Sort. Practice re- coding the

In C++ Please!
image text in transcribed
Lab&A: For this part of the lab, refer to the lecture slides for a review of Bubble Sort. Practice re- coding the algorithm given in lecture. Write a program that prompts the user to enter 10 numbers and stores the input in a 10 array of size 10. Now, use Bubble Sort to sort the array-continuously pushing the largest elements to the right side of the array. Every time you swap two elements in the array, you need to increment a counter. After the inner loop has completed, you need to print out the current state of the array and the total number of swaps that have occurred. Your output should look like the sample outputs shown below. User input is shown in bold. Note: Sample output #1 shows the worst case scenario" because it has the maximum number of swaps possible. Sample output #2 shows the "average scenario because it has approximately half the number of swaps. Your last step is to create an fstream variable for writing to a file. Call this file "Ouput.csv". You need to write each value in the array to this csv file and use a comma to separate each value. Then, close your fstream. Check to make sure you've completed this part correctly by opening the csv file in Excel (or the equivalent), then take a screenshot as evidence that it is working. You will submit this screenshot as part of your lab Refer to the Appendix for more information. Note: Pay attention to where your project is saved. By default, it will be saved in the same directory as your source code, but it may also be in the "Debug" directory of your project. Remember where it's saved because you'll need to know that for Lab8b! Sample output 11 Enter slot 0: 10 Enter slot 1: 9 Enter slot 2: 8 Enter slot 3: 7 Enter slot 4: 6 Enter Slot S: 5 Enter blot 6:4 Enter Slot 7; 3 Enter Slot 8: 2 Enter slot 9: 1 91817161514131211101 Num swaps: 9 81716151413121191101 Num swaps: 17 Sample output 12 Enter slot 0 : 5 Enter slot 1:10 Enter alot 2: 8 Enter slot 3: 2 Enter slot 4: 1 Enter slot 5: 6 Enter slot 6: 7 Enter slot 7: 3 Enter Slot 8: 9 Enter slot 9:4 518121116171319141101 Num swaps: 8. 512111617131814191101 Num swaps: 14

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

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions