Question: Consider the following algorithm which receives as input an array A of size n: i 1 while i < = ndo sum 0 prod 1
Consider the following algorithm which receives as input an array A of size n:
i
while i ndo
sum
prod
for j to n do
sum sum Aj
for j to n do
prod prod Aj
i i
State how many times each loop is executed and justify your answer.
Give the running time of the algorithm in Theta notation. Explain how you reached the
answer
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
