Question: in C++ Sorting Orders Write a program that uses two identical arrays of eight integers. It should display the contents of the rst array, then

in C++

Sorting Orders Write a program that uses two identical arrays of eight integers. It should display the contents of the rst array, then call a function to sort it using an ascending order bubble sort, modied to print out the array contents after each pass of the sort. Next the program should display the contents of the second array, then call a function to sort it using an ascending order selection sort, modied to print out the array contents after each pass of the sort. Please use the data in the test case and display all intermediate values for the array as you go through each pass as shown below:

Bubble Sort The unsorted values are: 7 2 3 8 4 5 6 1 sort pass #1 : 2 7 3 8 4 5 6 1

sort pass #2 : 2 3 7 8 4 5 6 1

sort pass #3 : 2 3 7 4 8 5 6 1

sort pass #4 : 2 3 7 4 5 8 6 1

sort pass #5 : 2 3 7 4 5 6 8 1

sort pass #6 : 2 3 7 4 5 6 1 8

sort pass #7 : 2 3 4 7 5 6 1 8

sort pass #8 : 2 3 4 5 7 6 1 8

sort pass #9 : 2 3 4 5 6 7 1 8

sort pass #10 : 2 3 4 5 6 1 7 8

sort pass #11 : 2 3 4 5 1 6 7 8

sort pass #12 : 2 3 4 1 5 6 7 8

sort pass #13 : 2 3 1 4 5 6 7 8

sort pass #14 : 2 1 3 4 5 6 7 8

sort pass #15 : 1 2 3 4 5 6 7 8

The sorted values are: 1 2 3 4 5 6 7 8

Selection Sort

The unsorted values are: 7 2 3 8 4 5 6 1

sort pass #1 : 1 2 3 8 4 5 6 7

sort pass #2 : 1 2 3 8 4 5 6 7

sort pass #3 : 1 2 3 8 4 5 6 7

sort pass #4 : 1 2 3 4 8 5 6 7

sort pass #5 : 1 2 3 4 5 8 6 7

sort pass #6 : 1 2 3 4 5 6 8 7

sort pass #7 : 1 2 3 4 5 6 7 8

The sorted values are: 1 2 3 4 5 6 7 8

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!