Answer to Question #270940 in C++ for Vera warren

Question #270940

ACTIVITY 2:


# A is the array and n is the array size


def sum(A,n):

total =0

for i in range(n):

total = total + A [ i ]

return total




1. How many times did the operation execute? 

Answer: n times

2. What is the final time complexity of the given algorithm?

Answer: O(n)

3. What is the final space complexity of the given algorithm?

Answer: O(n)




1
Expert's answer
2021-11-24T14:11:01-0500

1) The operation has been executed n times.

2) Time Complexity O(n) because it has been executed n times.

3) Space Complexity O(n) because it has been executed 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