[Verification and Validation]
The function
is supposed to find the maximum of the row-wise minimum values of
the integers in the given 2D-array
, i.e.
The function should return -1 if the given array is empty or in
case all rows in the array are empty. The program below contains an
implementation of this function.
1) Draw a control flow graph for the program above.
2) Find a test suite which satisfies a highest degree of edge coverage on the graph given in 1).
import java.lang.*;
import java.util.*;
class MaxProg
{
int maxOfMin(int[][] arr)
{
int max,min;
max=-1;
for(int j=0;j<arr.length;j++)
{
if(arr[j].length==0)
{
continue;
}
else
{
min=arr[j][0];
}
int i=1;
while(i<arr[j].length)
{
if(min<=max)
break;
if(arr[j][i]<min)
{
min=arr[j][i];
}
i++;
}
if(min>max)
max=min;
}
return max;
}
}
class max_min
{
public static void main(String args[])
{
int arr[][]={{3,2,1},{},{5,6,4},{1,2,3}};
MaxProg d=new MaxProg();
System.out.println("max of min value is "+d.maxOfMin(arr));
}
}
control flow graph is:
the best test suit was
{{3,2,1},{},{-1,2,3},{5,6,4}}
in the above test suit we are giving last elements as small element,so loop will continue until the last element in every row.
we are using an empty row ,so continue will work in the above flow graph.
in the third row we are using -1, so min value is equal to default max value so break statement will work.
and finally max element in the all minimum elements is place in last row. it will check for all the pridicates in the flow graph.
[Verification and Validation] The function is supposed to find the maximum of the row-wise minimum values...
1 I You can print the values to stdout for debugging You are required to fix all logical errors in the given code. You can click on Compile & Run anytime to check the compilation/execution status of the program. You can use System.outprintin to debug your code. The submitted code should be logically/syntactically correct and pass all testcases. Do not write the mainli function as it is not required. Code Approach: For this question, you will need to correct the...
Find the maximum value and minimum value in milesTracker. Assign
the maximum value to maxMiles, and the minimum value to minMiles.
Sample output for the given program:
Find the maximum value and minimum value in miles Tracker. Assign the maximum value to maxMiles, and the minimum value to minMiles. Sample output for the given program Min miles: -10 Max miles: 40 (Notes) 1 import java.util.Scanner 3 public class ArraysKeyValue 4 public static void main (String passe args) i final int...
how to do part A B and C?
Use Lagrange multipliers to find the maximum and minimum values of the function f subject to the given constraints g and h f(x, y, z)-yz-6xy; subject to g : xy-1-0 h:ỷ +42-32-0 and a) (i)Write out the three Lagrange conditions, i.e. Vf-AVg +yVh Type 1 for A and j for y and do not rearrange any of the equations Lagrange condition along x-direction: Lagrange condition along y-direction: Lagrange condition along z-direction: 0.5...
1. You are given a C file which contains a partially completed
program. Follow the instructions contained in comments and complete
the required functions. You will be rewriting four functions from
HW03 (initializeStrings, printStrings, encryptStrings,
decryptStrings) using only pointer operations instead of using
array operations. In addition to this, you will be writing two new
functions (printReversedString, isValidPassword). You should not be
using any array operations in any of functions for this assignment.
You may use only the strlen() function...
Assignment Predator / Prey Objectives Reading from and writing to text files Implementing mathematical formulas in C++ Implementing classes Using vectors Using command line arguments Modifying previously written code Tasks For this project, you will implement a simulation for predicting the future populations for a group of animals that we’ll call prey and their predators. Given the rate at which prey births exceed natural deaths, the rate of predation, the rate at which predator deaths exceeds births without a food...