Suppose that L is a list of 6,500 elements. Find the average number of comparisons made by bubble sort, selection sort, and insertion sort to sort L. (2) a.  It was remarked in this chapter that the...


Suppose that L is a list of 6,500 elements. Find the average number of comparisons made by bubble sort, selection sort, and insertion sort to sort L. (2)


a.  It was remarked in this chapter that the performance of bubble sort can be improved if we stop the sorting process as soon as we find that in an iteration no swapping of elements take place. Write a function that implements bubble sort algorithm using this fact. (2)


b.  Using the algorithm that you designed in part (a), find the number of iterations that are needed to sort the list: 65, 14, 52, 43, 75, 25, 80, 90, 95. (2)




May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here