Question: [Verification and Validation] Consider the following implementation of the function findMin which takes an array of integers as input and returns an integer value which,
[Verification and Validation]
Consider the following implementation of the function findMin which takes an array of integers as input and returns an integer value which, supposedly, is the minimum element in the array.
![[Verification and Validation] Consider the following implementation of the function findMin which](https://s3.amazonaws.com/si.experts.images/answers/2024/08/66d2d32e40d74_65366d2d32d9d0f0.jpg)
1) Draw a control flow graph of this function in which each node n in the graph is labeled with the set Def(n) and the set Use(n), where
Def(n) = the set of variables which are defined (i.e. they are assigned some values) at node n.
Use(n) = the set of variables which are accessed (i.e. their values are read) at node n.
Note: In this function, the variables that we are interested in are arr, min, and i.
2) Find a smallest set of test paths in your graph which satisfies All-Defs coverage. Is there a set of test input which produces your set of test paths? If there is one, describe such a set of test input.
3) Find a smallest set of test paths in your graph which satisfies All-Uses coverage. Is there a set of test input which produces your set of test paths? If there is one, describe such a set of test input.
public int findMin (int[] array) t 1: 2 3 if array. length = 0) return -1; int min = array [0] ; int i=0; while( 1array. length) { 5 6 7 8 9 10: if (min array[1]) min = array[1] return min; 12: public int findMin (int[] array) t 1: 2 3 if array. length = 0) return -1; int min = array [0] ; int i=0; while( 1array. length) { 5 6 7 8 9 10: if (min array[1]) min = array[1] return min; 12
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
