Question: in this section you are asked to analyse the worst- case computational time complexity of python functions. Always identify the order of growth in the
in this section you are asked to analyse the worst- case computational time complexity of python functions. Always identify the order of growth in the tightest and simplest possiple form using big-o notation, e.g, write O(n) instead of O(2n+n/2).
a) state the overall wrost-case time complexity of the below function and provide a short explaination of your answer. the function accepts as input a list, lst, of positive numbers. analyse the function in terms of the lengeth of the input list (n=len(lst))
def mystery(lst):
total = 0
n = len(lst)
for i in range(n):
for j in [i+1, n]:
total += sum(lst[i:j])
return total
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
