Assume you have the following compute function, using python built-in sum function:
def compute(a_list):
for i in range(0, n): #Line 1
number = sum(a_list[0:i + 1])/(i+1) #Line 2
return number
What would the time-complexity for something like this look like?
Line 1 is executed n number of times, but Line 2, having the built-in sum function (O(n)), would it execute n^2 number of times? Therefore the algorithm would be O(n^2).
For each iteration of i, Line 2 is executed 1 + 2 + 3 + ... + n-2 + n-1 + n. The sum of these terms is
Is this correct?

ncome from? I'd guess eithern = len(a_list)ordef compute(a_list, n)…