Question: answer the 3 questions above using the algorithm MaxMin(A:array [1...n] of number) 1 if n is odd then 2 then max=min=A[n] 3 else max= -00;
![answer the 3 questions above using the algorithm MaxMin(A:array [1...n] of](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f13dcfed8a3_03166f13dcf74c3e.jpg)
answer the 3 questions above using the algorithm
MaxMin(A:array [1...n] of number) 1 if n is odd then 2 then max=min=A[n] 3 else max= -00; max = 0 4 for i=1 to n/2] 5 if A[2i-1]max then max=large Does the above algorithm correctly find the max and min numbers in the input array? What are its legal inputs? Write an algorithm to find max and min using the strategy of scanning the array left to right, keeping track of the max and min numbers using two local variables. How is the above given algorithm's strategy different from the left to right scanning? Which algorithm is more efficient - the above one or yours
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
