Professional Documents
Culture Documents
2
III B.Tech II Semester Supplimentary Examinations,January 2010
COMPILER DESIGN
Computer Science And Engineering
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
?????
4. Construct a DFA whose states are the canonical collection of LR(1) items for the
following augmented grammer:
S→A
A →BA |∈
B → aB |b [16]
1
Code No: 36024 R05 Set No. 2
for i := 1 to n do
for j:=1 to n do
c[i, j] :=0;
for i := 1 to n do
for j:=1 to n do
for k :=1 to n do
c[i, j] :=c[i , j] +a[i ,k] *b [k ,j]
end
(a) Assuming a, b, and c are allocated static storage and there are four bytes per
word in a byte-addressed memory, produce three-address statements for the
above program.
(b) Find the induction variables of each loop and eliminate them wherever possible
[8+8]
?????
2
Code No: 36024 R05 Set No. 4
III B.Tech II Semester Supplimentary Examinations,January 2010
COMPILER DESIGN
Computer Science And Engineering
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
?????
(a) An array of pointers to reals, where array index ranages from 1 to 100.
(b) A two dimensional array of integers (i.e. an array of array) whose rows are
indexed from 0 to 9 and whose columns are indexed from -10 to 10.
(c) Functions whose domains are functions from integers to pointers to integers
and whose ranges are records consisting of an integer and a character. [5+5+6]
3. (a) Write an algorithm for linear search with respect to an ordered symbol table
organization.
(b) Write an algorithm for binary search with respect to an ordered symbol table
organization. [8+8]
4. (a) What is regular expression? Write regular expressions for the following pat-
terns:
identifiers and float constants.
(b) Define lexeme, token and pattern. Identify the lexemes, that make up the
tokens in the following program segment. Indicate corresponding token and
pattern. [6+10]
5. Consider the following program which counts the primes form 2 to n using the Sieve
method on a suitably large array
begin
read n
for i : = 2 to n do
3
Code No: 36024 R05 Set No. 4
a[i] : = true / * initialize */
count: = 0;
for i : 2 to n ** .5 do
if a [i] then /* i is a prime */
begin
count := count +1
for j : = 2 * i to n by i do
a[j] : =false
/ * j is divisible by i */
end ;
print count
end
(a) Translate the above program into three address statements assuming a is al-
located static storage.
(b) Construct a flow graph from the three address statements and indicate the
back edges and their natural loops [8+8]
6. (a) What is Unreachable Code? Explain a technique for the removal of unreach-
able instructions with an example
(b) Explain Flow-of-Control Optimization technique [8+8]
?????
4
Code No: 36024 R05 Set No. 1
III B.Tech II Semester Supplimentary Examinations,January 2010
COMPILER DESIGN
Computer Science And Engineering
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
?????
2. (a) Explain the different phases of a compiler, showing the output of each phase,
using the example of the following statement:
position : = initial + rate * 60
(b) Compare compiler and interpreter with suitable diagrams. [10+6]
7. What is the necessity of creating an intermediate code form during the compiletion
process? Describe the various forms of intermediate code highlighting the utility of
each form. [16]
5
Code No: 36024 R05 Set No. 1
8. (a) Compare three different storage allocation strategies.
(b) Consider the following array declaration in ‘c’;
oat a[100][100];
Assume that the main memory in byte addressable and that the array is stored
starting from the memory address 100. What is the address of a[40][50]?[8+8]
?????
6
Code No: 36024 R05 Set No. 3
III B.Tech II Semester Supplimentary Examinations,January 2010
COMPILER DESIGN
Computer Science And Engineering
Time: 3 hours Max Marks: 80
Answer any FIVE Questions
All Questions carry equal marks
?????
2. (a) Explain the different phases of a compiler, showing the output of each phase
using the example for the statement:
x=(a+b) * (c+d)
(b) Write short notes on bootstrapping process. [8+8]
3. (a) What is an ordered and unordered symbol table? What is the function of
symbol table in the compliation process? Explain.
(b) What are the various attributes of a Symbol Table? [10+6]
4. (a) What is loop invariant operation? Write an algorithm for detecting loop in-
variant computations.
(b) Consider the following program fragment code:
int p=1, k=0, n;
while(k<n)
{
p=2*p;
k=k+1;
}
Apply the invariant operation elimination on the above program segment:
[8+8]
7
Code No: 36024 R05 Set No. 3
read n
for i : = 2 to n do
a[i] : = true / * initialize */
count: = 0;
for i : 2 to n ** .5 do
if a [i] then /* i is a prime */
begin
count := count +1
for j : = 2 * i to n by i do
a[j] : =false
/ * j is divisible by i */
end ;
print count
end [6+10]
?????