An array contains the following elements 7 8 26 44 13 23 57
An array contains the following elements: 7 8 26 44 13 23 57 98. The first two elements have been sorted using a bubble sort. What would be the value of the elements in the array after three more passes of the bubble sort algorithm? Use the version that of bubble sort that starts from the end and bubbles up the smallest element. Your answer includes the intermediate results that the algorithm computes.
Solution
Second pass : 7 8 26 44 13 23 57 98
7<8
8<26
26<44
44>13
Swap
Then 7 8 26 13 44 23 57 98
Again 44>23
Swap again
7 8 26 13 23 44 57 98
44<57
57<98
Done
Third pass :
7 8 26 13 23 44 57 98
26>13
Swap
7 8 13 26 23 44 57 98
26>23
Swap
7 8 13 23 26 44 57 98 done
