Time and space complexity
Exercise 1
What is the time and space complexity of the following code:
a = 0
b = 0
for i in range(N):
a = a + random()
for i in range(M):
b= b + random()Exercise 2
What is the time complexity of the following code:
a = 0;
for i in range(N):
for j in reversed(range(i,N)):
a = a + i + j;Exercise 3
What is the time complexity of the following code:
k = 0
for i in range(n//2, n):
j = 2
while j <= n:
j = j * 2
k = k + n / 2Greedy Algorithms
Solve the challenges in this Colab notebook (open it with Google Colaboratory and save a copy in your Drive).
Complete the following challenges: