ACTIVITY 3: i +
def sum(n):
a = 0
for i in range(n):
for j in range(n, i, -1):
a = a + j;
return a
1. How many times did the operation execute?
Answer: n * n times
2. What is the final time complexity of the given algorithm?
Answer: O(n2)
3. What is the final space complexity of the given algorithm?
Answer: O(1
1. 1
2. n2
3. n*n times
Comments
Leave a comment