Question: Consider the following algorithm: Algorithm mysterious(A[O..n - 1]) //Input: Array A[O..n - 1] of numbers //Output: ????????????????????????? for i 0 to n - 1 do
Consider the following algorithm: Algorithm mysterious(A[O..n - 1]) //Input: Array A[O..n - 1] of numbers //Output: ????????????????????????? for i 0 to n - 1 do for jo to n - 1 do if i # j and A[i] - A[] > x XA[i] - A[] return x 1. What does this algorithm do? 2. Improve the algorithm by modifying the inner loop and its body. 3. Propose another better algorithm to solve the
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
