A different version of bubble sort keeps track of where the last exchange occurred, and on the next pass, it will not go past this point. If the last change was made in the swap of locations i and i + 1, the next pass will not look at any elements past location i. a. Write this new version of bubble sort. b. Write a short paragraph that explains exactly why this new version of bubble sort will work. c. Does this new version of bubble sort change the worst-case analysis? Give an analysis or justification for your answer. d. This new version of bubble sort does change the average-case analysis. Give a detailed explanation of what is involved in calculating this new average-case analysis.
Running head: BUBBLE SORT
A bubble sort that keeps track and compares where the last exchange took place in the…