Data 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;
6 i = 0;
7 while ( i < high )
8 {
9 if( V[ i ] > V [ i +1])
10 return -2;
11 i ++;
12 }
13
14 while ( low <= high )
15 {
16 mid = ( low + high )/2;
17 if ( X < V [ mid ])
18 high = mid - 1;
19 else
20 if ( X > V [ mid ])
21 low = mid + 1;
22 else
23 return mid ;
24 }
25 return -1;
26 }
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 data flow graph for the above binsearch() function.
2. Assuming that the input array V[ ] has at least one element in it, find an infeasible path in the data flow graph for the binsearch() function.
3. Find a set of complete paths satisfying the all-defs selection criterion with respect to variable mid.
4. Find a set of complete paths satisfying the all-defs selection criterion with respect to variable high.
5. Find a set of complete paths satisfying the all-defs selection criterion with respect to variable low.