Question: 2. (20 points) Explain why the bubble sort algorithm does (n) comparisons on an a list of n-elements? The following is the algorithm, you can

 2. (20 points) Explain why the bubble sort algorithm does (n)

2. (20 points) Explain why the bubble sort algorithm does (n) comparisons on an a list of n-elements? The following is the algorithm, you can also find it in exercise 11 of your textbook (page 141 in 7th Edition). 1. Get values for n and the n list items 2. Set the maker U for the unsorted section at the end of the list. 3. While the unsorted section has more than one element, do steps 4 through 8 4. Set the current element marker at the second element of the list 5. While c has not passed U, do steps 6 and 7 If the item at position is less than the item to its left, then exchange these two items 7. Move to the right one position Move U to the left one position 9. stop 8. AN

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!