Question: def bubbleSort (my_ list): for passnum in range( len( my list 1, , -1): if my_listl i] y listl i 1 ]: for i in

 def bubbleSort (my_ list): for passnum in range( len( my list

def bubbleSort (my_ list): for passnum in range( len( my list 1, , -1): if my_listl i] y listl i 1 ]: for i in range( passnum): temp = my-list [ i ] my-list [ i ] = my-listl i + 1 ] mylist [ i + 1] = temp return my list Note that the range function here takes 3 inputs instead of 1. Basically the range function here is incrementing from ln(list) - 1 to O using a step size of -1. More information can be found online in the official python documentation. 3.4 Analysis 1 (2 points) Assume we define complexity as the number of element comparisons we make (as we do on line 1), what would be the total runtime of this algorithm? 3.5 Analysis 2 (2 points) Assume we define complexity as the number of element swaps we make (as we do on lines 5-7) What would be the total runtime of this algorithm

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!