Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following code 1 int binsearch ( int X , int V [ ] , int n ) 2 { 3 int low ,

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.
1
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.

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

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions