Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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) { 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions