Question: Is my answer for this code in question 1 correct did I make my control flow graph correctly? Consider the following code 1 int binsearch
Is my answer for this code in question correct did I make my control flow graph correctly?
Consider the following code
int binsearch int X int V int n
int low high mid i ;
low ;
high n ;
for i ; i high ; i
if V i V i
return ;
while low high
mid low high ;
if X V mid
high mid ;
else
if X V mid
low mid ;
else
return mid ;
return ;
This code takes as input a sorted array V of size n and an integer X if X exists in the array it will rDraw a Control flow graph for binsearch
Initialize: binsearchint X int V int n
low
high
: Investigateeturn the index of X else it will return
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
