Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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] 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started