Docsity

CS 795 Midterm Exam, Spring 2005 - Prof. Ravi Mukkamala, Exams of Computer Science

Toggle sidebar
bg1
CS 795: Midterm
Spring 2005
Mail to cmo by Mar. 1
1. (10 pts) Complete the homework from slide set 3, slide 11.
2. (15 pts) Find several commercial code analysis tools. Describe briefly what
they to. Bonus point for finding free academic tools from active research
projects.
/* 1 */ /* Sample code for slicing exercise. v. 2/21/05 */
/* 2 */ #include <iostream.h>
/* 3 */ void main()
/* 4 */ {
/* 5 */ const int reps=10;
/* 6 */ int i;
/* 7 */ int a, b, c, d;
/* 8 */ cin >> a;
/* 9 */ cin >> b;
/* 10 */
/* 11 */ c = 2*a + a*b;
/* 12 */ d = 3*a + b;
/* 13 */ for ( i=0; i<= reps; i++ )
/* 14 */ {
/* 15 */ if ( c < 0 )
/* 16 */ {
/* 17 */ a = 2*a;
/* 18 */ c = c+5;
/* 19 */ }
/* 20 */ else
/* 21 */ {
/* 22 */ c = 2*a + a*b;
/* 23 */ d = 3*a + b;
/* 24 */ }
/* 25 */ }
/* 26 */ cout << c << endl;
/* 27 */ }
3. (25 pts) For the provided program, let C=< 27, {c} >. To do this, for each
statement in the program, compute R0C(n), B0c(n), and S0c(n), INFL(n), along
with higher orders (R1C(n), etc.
pf2

Partial preview of the text

Download CS 795 Midterm Exam, Spring 2005 - Prof. Ravi Mukkamala and more Exams Computer Science in PDF only on Docsity!

CS 795: Midterm

Spring 2005

Mail to cmo by Mar. 1

1. (10 pts) Complete the homework from slide set 3, slide 11.

2. (15 pts) Find several commercial code analysis tools. Describe briefly what

they to. Bonus point for finding free academic tools from active research

projects.

/* 1 / / Sample code for slicing exercise. v. 2/21/05 / / 2 / #include <iostream.h> / 3 / void main() / 4 / { / 5 / const int reps=10; / 6 / int i; / 7 / int a, b, c, d; / 8 / cin >> a; / 9 / cin >> b; / 10 / / 11 / c = 2a + ab; / 12 / d = 3a + b; /* 13 / for ( i=0; i<= reps; i++ ) / 14 / { / 15 / if ( c < 0 ) / 16 / { / 17 / a = 2a; /* 18 / c = c+5; / 19 / } / 20 / else / 21 / { / 22 / c = 2a + ab; / 23 / d = 3a + b; /* 24 / } / 25 / } / 26 / cout << c << endl; / 27 */ }

3. (25 pts) For the provided program, let C=< 27, {c} >. To do this, for each

statement in the program, compute R^0 C(n), B^0 c(n), and S^0 c(n), INFL(n), along

with higher orders (R^1 C(n), etc.

4. (15 pts) Transform the program of question 2 into an equivalent program

containing only sequence, assignment, if, if-then-else and while-do. Then find

the Bergeretti and Carré information-flow relations λs, μs, and ρs where S is

your transformed program.

Request: I haven’t done this, and some of the tasks can get more time

consuming than they are worth. Please plan to give me a progress report in

class or by e-mail if it starts to take a lot of time.

5. (10 pts) For a program with n statements, what is an upper bound on the

number of edges in the control flow graph for that program? Justify your

answer.

6. (10 pts) Can a static code analysis tool detect all occurrences of uninitialized

variables? Justify your answer.

7. (10 pts) Can a dynamic code analysis tool detect all occurrences of

uninitialized variables? Justify your answer.

8. (10 pts) Give an example (through a code fragment) of an alias which is

introduced through function parameters.

9. (10 pts) It is asserted in slide set two that "At some point, Sci+1^ will equal

Sic". Explain why this is so.

10. (10 pts) In order to deal with functions, Weiser introduces two

mappings, one from actual parameter names to formal parameter

names, the other from formal parameter names to actual parameter

names. Why are these needed?