Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[Verification and Validation] The following is an implementation of the function findMiddle , which is expected to find an element in the given array that

[Verification and Validation]

The following is an implementation of the function findMiddle, which is expected to find an element in the given array that is closest to the average of the elements in the array.

image text in transcribed

Below is a control flow graph of the program.

image text in transcribed

Answer the following questions.

1.) What is the path produced by the input: arr = [2]? 2.) What is the path produced by the input: arr = [4, 5, 1, 3]? 3.) Find a test input which produces the test path [1, 2, 3, 2, 3, 2, 3, 2, 4, 5, 6, 8, 5, 6, 8, 5, 6, 7, 8, 5, 9]. 4.) Find a test path which is not produced by any test input. 5.) Find all the nodes n such that Def(n) contains k. (In other words, find all the nodes n where the variable k is assigned a value.) 6.) Find all the nodes n such that Use(n) contains sum. (In other words, find all the nodes n where the value of the variable sum is read.) 7.) Find two DU-paths with respect to the variable sum. 8.) Find all the nodes to which there is a DU-path from node 4 with respect to the variable k.

1 public static int findMiddle (int[] arr) sum, middle; int k, double mean; sum = 0; for (k 0; k arr . length ; k++) 4 sum += arr [k] mean = sum arr. length; middle = arr[0] ; for (k 0; k

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

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions

Question

What lessons in OD contracting does this case represent?

Answered: 1 week ago

Question

Does the code suggest how long data is kept and who has access?

Answered: 1 week ago