Question: control flow testing. Consider the following code 1 int binsearch ( int X , int V [ ] , int n ) 2 { 3

control flow testing. Consider the following code 1 int binsearch (int X , int V [], int n )2{3 int low , high , mid , i ; 4 low =0; 5 high = n -1; 67 for ( i =0; i < high ; i ++)8{9 if( V[ i ]> V [ i +1])10 return -2; 11}1213 while ( low <= high )14{15 mid =( low + high )/2; 16 if ( X < V [ mid ])17 high = mid -1; 18 else 19 if ( X > V [ mid ])20 low = mid +1; 21 else 22 return mid ; 23}24 return -1; 25} This code takes as input a sorted array V of size n, and an integer X, if X exists in the array it will return the index of X, else it will return -1.1. Draw a CFG for binsearch().2. From the CFG, identify a set of entryexit paths to satisfy the complete statement coverage criterion. 3. Identify additional paths, if necessary, to satisfy the complete branch coverage criterion. 4. For each path identified above, derive their path predicate expressions. 5. Solve the path predicate expressions to generate test input and compute the corresponding expected outcomes. 6. Are all the selected paths feasible? If not, select and show that a path is infeasible, if it exists. 7. Can you introduce two faults in the routine so that these go undetected by your test cases designed for complete branch coverage? 8. Suggest a general way to detect the kinds of faults introduced in the previous step.

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 Databases Questions!