Question: ne, ve written the?unction , bubblesort, bel0. It takes In #one list parameter, 1st. However, there are two problems in four current code -There's a

ne, ve written the?unction , bubblesort, bel0. It takes In #one list parameter, 1st. However, there are two problems in four current code -There's a missing line -There's a semantic error (the code does not raise an # error message, but it does not perform correctly) #71nd and fix these problems! Note that you should only need #to change or add code where explicitly ndicated. #3int : If you're stuck, use an example input list and trace the code and how it modifies your list on paper. For example, try writing out what happens to the following list: [34, 16, 2, 78, 4, 6, 1 def bubbleSort (lst): #set swapoccurred to True to guarantee the loop runs once swapOccurred - True #Aun the loop as long as a swap occurred the previous time while swapOccurred: #Start off assuming a swap did not occur swapoccurred False #For every item in the list except the last one... for i in range(len (1st)1) #If the item should swap with the next item if lst[i] > lst[i + 11: Then, swap them! But these lines aren't quite right: fix this code! 1st[i] -lst [ i + 1] temp = lst[i] lstli + 1 temp #one more line is needed here; add it! return lst eThe line below will test your code. If it works, a sorted #11st will be printed. This is not used for grading, so feel free to change it. print (bubbleSort([5, 3, 1, 2, 4]))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
