Question: Answer part a and b. Please show steps. Thanks. 2. 6 marks] Worst-case analysis. Consider the following function, which takes in a list of integers.

Answer part a and b. Please show steps. Thanks. 2. 6 marks]Answer part a and b. Please show steps. Thanks.

2. 6 marks] Worst-case analysis. Consider the following function, which takes in a list of integers. 1 def my_algorithm (L: List [int]) > None: 2 n = len(L) i=n-1 total = 0 while i = 0: 4 6 if L[i] 0: 7 total = total + i while total 0: 9 10 total = total - 1 i=i-2 else: 12 13 14 total = total + n 1=1-1 Let WC(n) be the worst-case runtime function of my algorithm, where n represents the length of the input list L (a) [3 marks] Determine and prove a tight upper bound on WC(n). (b) 3 marks] Determine and prove a tight lower bound on WC(n)

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!