Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Bubble Sort Improvement: Improve the performance of the bubble sort from the oth

ID: 3618098 • Letter: B

Question

 Bubble Sort Improvement: Improve the performance of the bubble sort from the other
question
with the following: After the first pass, the largest is guaranteed to be in the
last index. So,
at each iteration of the bubble algorithm, only make the necessary comparisons, i.e.
do 9 ( assuming 10 values) comparisons at second iteration, 8 at third, etc.

Expected Output:

Original Data
23 22 12 23 37 69 3 89 4 99
After pass #1 : 22 12 23 23 37 3 69 4 89
After pass #2 : 12 22 23 23 3 37 4 69
After pass #3 : 12 22 23 3 23 4 37
After pass #4 : 12 22 3 23 4 23
After pass #5 : 12 3 22 4 23
After pass #6 : 3 12 4 22
After pass #7 : 3 4 12
After pass #8 : 3 4
After pass #9 : 3
Data items in ascending order
3 4 12 22 23 23 37 69 89 99

Number of Comparisons made = 45


Explanation / Answer

I am not going to write out the whole program, but here is theidea. long number;    // the number of items in thelist long temp;     // temporary value for a numberto be stored long x[10];      // array containing thevalues to be sorted for (long k=1;k
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote