Question: Given the following method: 01 public static double median (double[] d) { double median = Double. NaN; 02 03 04 if (d != null

Given the following method: 01 public static double median (double[] d) { 

Given the following method: 01 public static double median (double[] d) { double median = Double. NaN; 02 03 04 if (d != null && d.length > 0) if (d.length == 1) { median = d[0]; } else { Arrays.sort(d); // sorted ascending int mid = d.length / 2; if (d.length % 2 != 0) { median = d[mid]; } else { 05 06 07 08 09 10 11 12 13 } 14 } 15 } 16 17 } median = (d[mid - 1] + d[mid]) / 2; return median; a) Justify: What would be the effect if you replace "&&" in line 3 with a "&"? (2 Points) b) Create the control flow graph of the method median(...). Please write the source code, references to the line numbers of the method are not sufficient. (5 Points) c) Specify a test case (minimum input numbers) which satisfies the statement coverage for the method median (...). Enter the paths that have been traversed. (3 Points)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!