Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following program is a binary search program in C. int search ( int key, int [] elemArray) { int bottom = 0; int top

The following program is a binary search program in C.

int search ( int key, int [] elemArray)

{

int bottom = 0;

int top = elemArray.length - 1;

int mid;

int result = -1;

while ( bottom <= top )

{

mid = (top + bottom) / 2;

if (elemArray [mid] == key)

{

result = mid;

return result;

} // if part

else

{

if (elemArray [mid] < key)

bottom = mid + 1;

else

top = mid - 1;

}

} //while loop

return result;

} // search

1. Identify the basic blocks and draw the flow graph.

2. Identify as many independent paths as possible with a minimum of three paths.

3. Of these paths, classify the paths as simple path and loop-free path.

4. Identify the definition, P-uses and C-uses. You could use the following format.

Statements

Def

P-Use

C-Use

Statement 1

X

Statement 2

X

Statement n

X

X

5. Identify the def-use associations of variables like bottom, top and mid.

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

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago