Answer to Question #270945 in C++ for Angelie Suarez

Question #270945

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
Expert's answer
2021-11-24T08:04:40-0500

1. 1

2. n2

3. n*n times


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS