Question: 5 . Consider the following algorithm that updates the values in the array A . ( a ) ( 3 marks ) Compute the time
Consider the following algorithm that updates the values in the array A
a 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 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 ; while i n do if i then
step
end else if Ai then AiAi; step ;
end i i step; end
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
