You are on page 1of 1

1. . What is the execution time and time complexity of the algorithm below?

def s(a, j):


prefix_sum = 0
while j >= 0:
i=0
while i <= j:
prefix_sum += a[i]
i += 1
j -= 1
return prefix_sum

2. . What is the execution time and time complexity of the algorithm below?
def Fibonacci(n):
if n in [0, 1]:
return n
else:
return Fibonacci(n-1) + Fibonacci(n-2)

You might also like