ECE 573
Problem Set 9: Dependence analysis
1. Consider the following code:
for (int i = 0; i < 6; i+) cfw_
for (int j = 0; j < 6; j+) cfw_
A[i][j] = A[i - 1][j + 1] + A[i + 1][j + 1];
(a) Draw the i
ECE 573 Midterm 1
September 29, 2009
Name:
_
Purdue email: _
Please sign the following:
I afrm that the answers given on this test are mine and mine alone. I did not receive
help from any person or m
ECE 573 Midterm 1
February 22, 2011
Name:
_
Purdue email: _
Please sign the following:
I afrm that the answers given on this test are mine and mine alone. I did not receive
help from any person or ma
ECE 573 Midterm 2
April 5, 2011
Name:
_KEY_
Purdue email: _
Please sign the following:
I afrm that the answers given on this test are mine and mine alone. I did not receive
help from any person or ma
ECE 573
Problem Set 1: Regular expressions and nite automata
1. Give a regular expression that will accept all valid names. A name consists of a
rst name, an optional middle name or initial, and a las
ECE 573
Problem Set 2: Context free grammars, recursive descent parsers and LL(1) parsers.
For the following problems, consider this context-free grammar:
1. S Xa
2. X Y Xb
3. X
4. Y cd
1. Can this l
ECE 573
Problem Set 3: LL(1) & LR(0) grammars
1. Give the rst and follow sets for the non-terminals of the following grammar:
1. S X $
2. X aXB
3. X bAB
4. A a
5. B b
6. B
Answer:
First
S
X
A
B
sets:
ECE 573
Problem Set 4: LR(1) parsers
1. Build the CFSM for this grammar. Is it an LR(0) grammar? Why or why not?
1. S AB $
2. A xy
3. A xB
4. B yz
Answer:
State 0
S AB $
A xy
A xB
State 1
A
State 2
S
ECE 573
Problem Set 7: CFGs and loop optimizations
Consider the following code:
1: a = b * 2;
L1: 2: if (a >= c) goto L4;
3: d = 3*a + 4;
4: if (d <= c) goto L2;
5: x = 2 * c;
6: y = 7;
7: goto L3;
L2
ECE 468
Problem Set 7: Dataow analysis
1. Show the results of running a reaching denition analysis on the following piece
of code: For each line of code, show which denitions reach that line of code b
ECE 573 Midterm 1
September 29, 2009
Name:
_
Purdue email: _
Please sign the following:
I afrm that the answers given on this test are mine and mine alone. I did not receive
help from any person or m