Home /
Expert Answers /
Computer Science /
solve-using-c-single-dimensional-arrays-and-c-strings-reference-of-7-14-solve-the-first-que-pa369

solve using c++

Single-Dimensional Arrays and C-Strings

reference of 7.14

solve the first question using c++

(Reverse bubble sort) In Programming Exercise 7.14, you used bubble sort to sort an array. The bubble sort function repeatedly compares the successive neighboring pairs in the array and swaps them if they are in decreasing order. Modify this program by swapping successive neighboring pairs if they are in increasing order. Write a test program that reads in an array of 15 integers, invokes the function, and displays the numbers sorted in decreasing order.
I4 (Bubble sort) Write a sort function that uses the bubble-sort algorithm. The algorithm makes several passes through the array. On each pass, successive neighboring pairs are compared. If a pair is in decreasing order, its values are swapped; otherwise, the values remain unchanged. The technique is called a bubble sort or sinking sort because the smaller values gradually "bubble" their way to the top and the larger values sink to the bottom. The algorithm can be described as follows: Clearly, the list is in increasing order when the loop terminates. It is easy to show that the do loop executes at most 1istSize - 1 times. Write a test program that reads in an array of ten double numbers, invokes the function, and displays the sorted numbers.

Your answer is here changed = false; for (int j = 0; j< listSize - 1; j++).. ••••••••••••••••••••••• #include