Question: Write two C++ functions bubblesort() and cocktailsort(), given a text file numbers.txt that contains 20 positive integers unsorted. Write a program that reads the numbers

Write two C++ functions bubblesort() and cocktailsort(), given a text file numbers.txt that contains 20 positive integers unsorted.

Write two C++ functions bubblesort() and cocktailsort(), given a text file numbers.txtthat contains 20 positive integers unsorted. Write a program that reads the

Write a program that reads the numbers from the provided file and then displays them in the Console Window is ascending order, using both the bubble sort and the cocktail sort method. Your program should include at least two functions: one for the bubble sort algorithm, one for the cocktail sort algorithm. Note: You might also want to write and use a function that swaps two values. You also need to display the number of comparisons and the number of swaps executed by each method. Your output in the Console Window should look like this: Bubble Sort 1 1 2 3 3 3 3 4 4 5 6 7 7 7 8 9 10 13 15 17 Number of Comparisons Number of swaps Cocktail Sort 1 1 2 3 3 3 3 4 4 5 6 7 7 7 8 9 10 13 15 17 Number of Comparisons Number of swaps

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!