Question: 5 . Consider the following algorithm that updates the values in the array A . ( a ) ( 3 marks ) Compute the time

5. Consider the following algorithm that updates the values in the array A.
(a)(3 marks) Compute the time complexity of this algorithm in the best case. You must explain how you computed the time complexity, and you must give the order of the complexity.
(b)(3 marks) Compute the time complexity of this algorithm in the worst case. You must explain how you computed the time complexity, and you must give the order of the complexity.
Data: Array A storing n integer values Result: None i 0; while i < n do if i =0 then
step 1
end else if A[i]>0 then A[i]A[i]; step 1;
end i i + step; end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!