Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 int binsearch ( int X , int V [ ] , int n ) 2 { 3 int low , high , mid ,

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. Please actually draw it
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.

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_2

Step: 3

blur-text-image_3

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

OpenStack Trove

Authors: Amrith Kumar, Douglas Shelley

1st Edition

1484212215, 9781484212219

More Books

Students also viewed these Databases questions

Question

mple 10. Determine d dx S 0 t dt.

Answered: 1 week ago