Problem 2 Solution

$30.00 $24.00

At the beginning of class on the due date, submit your neatly presented solution with this page stapled to the front (10points). Given the following program (in pseudo-like language), construct two control flow graphs for the program. In the first, use maximal basic blocks; in the second, place each statement in its own basic block.…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Categorys:
Tags:

Description

5/5 – (2 votes)

At the beginning of class on the due date, submit your neatly presented solution with this page stapled to the front (10points).

Given the following program (in pseudo-like language), construct two control flow graphs for the program. In the first, use maximal basic blocks; in the second, place each statement in its own basic block. In both cases, label the nodes in the graphs with the numbers of the program statements.

procedure sqrt(real x):real real x1,x2,x3,eps,errval;

begin

1. x3 = 1

2. errval = 0.0

3. eps = .001

4. if (x <= 0.0)

  1. output(“illegal operand”);
  2. return errval;
  3. else

8. if (x < 1)

9. x1 = x;

10. x2 = 1;

  1. else
  2. x1 = eps;

13. x2 = x;

14. endif

15. while ( (x2-x1) >= 2.0*eps ) 16. x3 = (x1+x2)/2.0

17. if ( (x3*x3-x)*(x1*x1-x) < 0)

18. x2 = x3;

19. else

20. x1 = x3;

  1. endif;
  2. endwhile;
  3. return x3;
  4. endif;
  5. end.

1

Problem 2 Solution
$30.00 $24.00