Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1. Sopts [Exercise 16.2] Consider the program given below: 1: 2: 3: 4: 5: 6: void test Fn (int *x, int flag) { while (flag

image text in transcribed

Q1. Sopts [Exercise 16.2] Consider the program given below: 1: 2: 3: 4: 5: 6: void test Fn (int *x, int flag) { while (flag != 1) { flag = 1; *x = flag; // *x: value pointed by the pointer x (dereferenced) } if (*x >0) *x += 2; return; } 7: 8: 9: In answering the questions below, assume that x is not NULL. (a) Draw the control-flow graph (CFG) of this program. Identify the basic blocks with unique IDs starting with 1. Note that we have added a dummy source node, numbered 0, to represent the entry to the function. For convenience, we have also introduced a dummy sink node, although this is not strictly required (refer to the figure below). 0 Dummy source node 16 Your CFG to be completed n Dummy sink node (b) Is there a bound on the number of iterations of the while loop? Justify your answer. (c) How many total paths does this program have? How many of them are feasible, and why? (d) Write down the system of flow constraints (i.e., X0, X1, ...), including any logical flow constraints (e.g., dab + dcd = f), for the control-flow graph of this program

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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

Is the current human resources management system obsolete?

Answered: 1 week ago

Question

=+ how might this lead to faster growth in productivity?

Answered: 1 week ago