Question: Please find the loop invariant In the fourth and final iteration, data[5] = 3 > 2 but hi = 2 ? 4/2, so med becomes
Answer the following questions about the algorithm below, which attempts to find the median element of an odd-length array Input: data: an array with an odd number of integers Input: n: the length of data (odd) Output: element m in data such that (n 1)/2 elements are smaller and (n - 1)/2 elements are larger 1 Algorithm: BadMedian 2 med= data[1] s lo hi 0 4for i 1 to n-ido sif datalimed then if lo
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
