Question: Please ASAP. Thanks 1) Consider the following algorithm for finding the largest product of any two non-equal elements in an array of numbers. Modify and
1) Consider the following algorithm for finding the largest product of any two non-equal elements in an array of numbers. Modify and improve the time efficiency of the algorithm. Bold, circle, or highlight your changes. Explain Why? ( 30 points) 1) MaxSum(A[0,,n1]) 2) // Input: Array A[0,,n1] of numbers 3) //Output: Maximum sum of any two non-equal elements 4) dmax// negative infinity 5) for i0 to n1 do 6) for j0 to n1 do 7) If A(i)=A(j) and A(i)+A(j)>dmax 8) dmax=A(i)+A(j) 9) return dmax
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
