Question: 10.00 Consider the following code and answer the below questions CO def bubbleSort(alist) for passnum in range(len(alist)-10,-1): fori in range(passnum) if alist[i]>clist[i+1) temp = alist[i]
![def bubbleSort(alist) for passnum in range(len(alist)-10,-1): fori in range(passnum) if alist[i]>clist[i+1) temp](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f536b657ed4_35766f536b5ec779.jpg)
10.00 Consider the following code and answer the below questions CO def bubbleSort(alist) for passnum in range(len(alist)-10,-1): fori in range(passnum) if alist[i]>clist[i+1) temp = alist[i] alist[i] = alist[i+1] alist[i+1] = temp alist = (35, 25, 42, 15, 38, 30, 50) pubbleSort(alist) print(alist) bubbleSort(alist) print(alist) Time left 1:56:47 a) what are the best, and worst case complexities of the Bubble-Sort algorithm? [2 marks) b) Explain why the complexity of the best case will be as similar as the worst case in the above implementation even if the input list is already ordered. [2 marks) c) List two disadvantage of the bubble-sort algorithm. [2 marks] d) Write down the output of this code after 2 iterations. [4 marks) x
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
