QUESTION BANK III - CSE Dr. NAVALAR NEDUNCHEZHIYAN

QUESTION BANK
III - CSE
Dr. NAVALAR NEDUNCHEZHIYAN COLLEGE OF ENGINEERING
THOLUDUR – 606 303, CUDDALORE DIST
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
ANNA UNIVERSITY CHENNAI
YEAR: III / SEM VI
CS2352 PRINCIPLES OF COMPILER DESIGN
UNIT I LEXICAL ANALYSIS
9
Introduction to Compiling- Compilers-Analysis of the source program-The phasesCousins-The grouping of phases-Compiler construction tools. The role of the lexical
analyzer- Input buffering-Specification of tokens-Recognition of tokens-A language for
specifying lexical analyzer.
UNIT II SYNTAX ANALYSIS and RUN-TIME ENVIRONMENTS
9
Syntax Analysis- The role of the parser-Context-free grammars-Writing a grammar-Topdown
parsing-Bottom-up Parsing-LR parsers-Constructing an SLR(1) parsing table.
Type Checking- Type Systems-Specification of a simple type checker. Run-Time
Environments-Source language issues-Storage organization-Storage-allocation
strategies.
UNIT III INTERMEDIATE CODE GENERATION
9
Intermediate languages-Declarations-Assignment statements - Boolean expressionsCase statements- Backpatching-Procedure calls
UNIT IV CODE GENERATION
9
Issues in the design of a code generator- The target machine-Run-time storage
management-Basic blocks and flow graphs- Next-use information-A simple code
generator-Register allocation and assignment-The dag representation of basic blocks Generating code from dags.
UNIT V CODE OPTIMIZATION
9
Introduction-The principle sources of optimization-Peephole optimization- Optimization of
basic blocks-Loops in flow graphs- Introduction to global data-flow analysis-Code
improving transformations.
TOTAL:45 PERIOD
TEXT BOOK:
1. Alfred V. Aho, Ravi Sethi Jeffrey D. Ullman, “Compilers- Principles, Techniques, and
Tools”, Pearson Education Asia, 2007.
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
REFERENCES:
1. David Galles, “Modern Compiler Design”, Pearson Education Asia, 2007
2. Steven S. Muchnick, “Advanced Compiler Design & Implementation”, Morgan
Kaufmann Pulishers, 2000.
3. C. N. Fisher and R. J. LeBlanc “Crafting a Compiler with C”, Pearson Education,
2000.
SUBJECT CODE
SUBJECT NAME
: CS2352
: PRINCIPLES OF COMPILER DESIGN
UNIT-I
LEXICAL ANALYSIS
PART-A
1.
2.
(1 MARKS)
The following grammar
G = (N, T, P, S)
N = {S, A, B}
T = {a, b, c}
P : S → aSa
S → aAa
A → bB
B → bB
B → c is
A) is type 3
b) is type 2 but not type 3
1
c)is type 1 but not type 2
d)is type 0 but not type
The following grammar
G = (N, T, P, S)
N = {S, A, B, C, D, E}
T = {a, b, c}
P : S → aAB
AB
→
CD
CD
→
CE
C
→
aC
C
→
B
bE
→
bc is
a) is type 3
b)is type 2 but not type 3 c)is type 1 but not type 2
d)is type 0 but not type 1
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
3.
4.
III - CSE
The following grammar
G = (N, T, P, S)
N = {S, A, B, C}
T = {a, b, c}
P : S → aS
A → bB
B → cC
C → a is
a) is type 3
b)is type 2 but not type 3
c)is type 1 but not type 2
d)is type 0 but not type 1
c)is type 1 but not type 2
d)is type 0 but not type 1
The following grammar
G = (N, T, P, S)
N = {S, A, B, C, D, E}
T = (a, b, c}
P : S → ABCD
BCD
→
DE
D
→
aD
D
→
A
E
→
bE
E
→
c is
a) is type 3
6.
7.
8.
b)is type 2 but not type 3
Consider the following language
L = {anbncndn|n ≥ 1}
L is
a) CFL but not regular b)CSL but not CFL
c)regular
d)type 0 language but not type 1
Consider the following language
L = {anbn|n ≥ 1}
L is
a) CFL but not regular b)CSL but not CFL
c)regular
d)type 0 language but not type 1
Consider the following language
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
L = {anbmcpdq|n, m, p, q ≥ 1}
L is
a) CFL but not regular b)CSL but not CFL
III - CSE
c)regular
d)type 0 language but not type 1
9.
The following CFG is in
S → AB
B → CD
B → AD
B→b
D → AD
D→d
A→a
C→a
a) Chomsky normal form but not strong Chomsky normal form b)Weak Chomsky normal
form but not Chomsky normal form
b) Strong Chomsky normal form c)Greibach normal form
10.
The following CFG is in
S → aBB
B → bAA
A→a
B→b
a) Chomsky normal form but not strong Chomsky normal form b)Weak Chomsky normal form
but not Chomsky normal form
b) Strong Chomsky normal form d) Greibach normal form
11. The number of interchanges required to sort 5, 1, 6, 2 4 in ascending order using Bubble Sortis
(A) 6 (B) 5 (C) 7 (D) 8
12.
(A)
(B)
(C)
(D) AB
13. The complexity of multiplying two matrices of order m*n and n*p is
(A) mnp (B) mp (C) mn (D) np
14. Merging 4 sorted files containing 50, 10, 25 and 15 records will take____time
(A) O (100) (B) O (200) (C) O (175) (D) O (125)
15. For an undirected graph with n vertices and e edges, the sum of the degree of each vertex is equal to
(A) 2n (B) (2n-1)/2 (C) 2e (D) e2/2
16. In worst case Quick Sort has order
(A) O (n log n) (B) O (n2/2) (C) O (log n) (D) O (n2/4)
17. A full binary tree with 2n+1 nodes contain
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
(A) n leaf nodes (B) n non-leaf nodes (C) n-1 leaf nodes (D) n-1 non-leaf nodes
18. If a node in a BST has two children, then its inorder predecessor has
(A) no left child (B) no right child (C) two children (D) no child
19. A binary tree in which if all its levels except possibly the last, have the maximum number of nodes
and all the nodes at the last level appear as far left as possible, is known as
(A) full binary tree. (B) AVL tree. (C) threaded tree. (D) complete binary tree.
20. A linear list of elements in which deletion can be done from one end (front) and insertion can take
place only at the other end (rear) is known as a
(A) queue. (B) stack. (C) tree. (D) linked list.
1
2
3
4
5
6
7
8
9
10 11 12 13 14 15 16 17 18 19 20
B
C
A
D
D
B
A
C
C
D
B
A
A
A
C
B
B
B
A
A
PART-B
(2 MARKS)
21. What is a compiler? (A.U Nov/Dec 2007) (A.U May/June 2013)
A compiler is a program that reads a program written in one language–the source language and translates
it into an equivalent program in another language-the target language. The compiler reports to its user the
presence of errors in the source program.
22. What are the two parts of a compilation? Explain briefly. (A.U Nov/Dec 2007)
Analysis and Synthesis are the two parts of compilation. The analysis part breaks up the source
program into constituent pieces and creates an intermediate representation of the source program. The
synthesis part constructs the desired target program from the intermediate representation.
23. List the subparts or phases of analysis part.
Analysis consists of three phases:

Linear Analysis.

Hierarchical Analysis.

Semantic Analysis.
24. Depict diagrammatically how a language is processed. (A.U May/June 2007)
Preprocessor
Compiler
Assembler
Loader/ link editor
Target assembly program
Relocatable machine code
Source Program
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
Skeletal source program
Absolute machine code
25. What is linear analysis?
Linear analysis is one in which the stream of characters making up the source program is read from
left to right and grouped into tokens that are sequences of characters having a collective meaning. Also called
lexical analysis or scanning.
26. List the various phases of a compiler. (A.U Nov/Dec 2008)
The following are the various phases of a compiler:
 Lexical Analyzer

Syntax Analyzer

Semantic Analyzer
 Intermediate code generator
 Code optimizer
 Code generator
27. What are the classifications of a compiler? (A.U Nov/Dec 2009)
Compilers are classified as:
 Single- pass
 M u l t i -p ass
 Lo ad -an d – go
 Debugging or optimizing
28. What is a symbol table? (A.U Nov/Dec 2010) (A.U May/June 2013)
A symbol table is a data structure containing a record for each identifier, with fields for the
attributes of the identifier. The data structure allows us to find the record for each identifier quickly and to
store or retrieve data from that record quickly. Whenever an identifier is detected by a lexical analyzer, it
is entered into the symbol table. The attributes of an identifier cannot be determined by the lexical
analyzer.
29. Mention some of the cousins of a compiler. (A.U Nov/Dec 2007)
Cousins of the compiler are:

Preprocessors
 Assemblers

Loaders and Link-Editors
30. List the phases that constitute the front end of a compiler. (A.U Nov/Dec 2010)
The front end consists of those phases or parts of phases those depends primarily on the source language
and are largely independent of the target machine. These include

Lexical and Syntactic analysis

The creation of symbol table

Semantic analysis

Generation of intermediate code
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
A certain amount of code optimization can be done by the front end as well. Also includes error
handling that goes along with each of these phases.
31. Mention the back-end phases of a compiler. (A.U May 2008)
The back end of compiler includes those portions that depend on the target machine and generally
those portions do not depend on the source language, just the intermediate language. These include

Code optimization

Code generation, along with error handling and symbol- table operations.
32. Define compiler-compiler. (A.U Nov/Dec 2007) (A.U Nov/Dec 2012)
Systems to help with the compiler-writing process are often been referred to as compilercompilers, compiler-generators or translator-writing systems. Largely they are oriented around a particular
model of languages, and they are suitable for generating compilers of languages similar model.
33. List the various compiler construction tools.
The following is a list of some compiler construction tools:

Parser generators

Scanner generators

Syntax-directed translation engines

Automatic code generators

Data-flow engines
34. Differentiate tokens, patterns, and lexeme. (A.U May/June 2010) (A.U Nov/Dec 2012)

Tokens- Sequence of characters that have a collective meaning.
 Patterns- There is a set of strings in the input for which the same token is produced as output. This
set of strings is described by a rule called a pattern associated with the token

Lexeme- A sequence of characters in the source program that is matched by the pattern for a
token.
35. List the operations on languages.
o
Union - L U M ={s | s is in L or s is in M}
o
Concatenation– LM ={st | s is in L and t is in M}
o
Kleene Closure– L* (zero or more concatenations of L)
o
Positive Closure– L+ ( one or more concatenations of L)
36. Write a regular expression for an identifier.
An identifier is defined as a letter followed by zero or more letters or digits. The regular
expression for an identifier is given asletter (letter | digit)*
37. Mention the various notational shorthands for representing regular expressions.

One or more instances (+)

Zero or one instance (?)

Character classes ([abc] where a,b,c are alphabet symbols denotes the
Regular expressions a | b | c.) N

Non regular sets
38. What is the function of a hierarchical analysis?
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
Hierarchical analysis is one in which the tokens are grouped hierarchically into nested collections
with collective meaning. Also termed as Parsing.
39. What does a semantic analysis do?
Semantic analysis is one in which certain checks are performed to ensure that components of a
program fit together meaningfully. Mainly performs type checking.
40. List the various error recovery strategies for a lexical analysis.
Possible error recovery actions are:

Panic mode recovery

Deleting an extraneous character

Inserting a missing character

Replacing an incorrect character by a correct character

Transposing two adjacent characters
PART-C
(16 MARKS)
41. Explain in detail about the role of Lexical analyzer with the possible error Recovery actions. (A.U
Nov/Dec 2012)
42. (a) Describe the following software tools(A.U Nov/Dec 2007)
i. Structure Editors ii. Pretty printer’s iii. Interpreters
(b) Write in detail about the cousins of the compiler.
43. Describe in detail about input buffering. What are the tools used for constructing a compiler? (A.U
May/June 2013)
44. (a) Explain the functions of the Lexical Analyzer with its implementation.
(b) Elaborate specification of tokens. (A.U Nov/Dec 2008) (A.U May/June 2013)
45. (a) What is a compiler? Explain the various phases of compiler in detail, with a neat sketch.
(b) Elaborate on grouping of phases in a compiler. (A.U May/June 2010) (A.U Nov/Dec 2012)
46.(a) Explain the various phases of a compiler in detail. Also write down the output for the following
expression after each phase a: =b*cd. (A.U May/June 2013)
(b) What are the phases of the compiler? Explain the phases in detail. (A.U Nov/Dec 2009)
Write down the output of each phase for the expression a: = b +c * 50.
UNIT-II
PART-A
46
SYNTAX ANALYSIS & RUNTIME ENVIRONMENTS
(1 MARKS)
Consider a language L for which there exists a Turing machine (TM), T,
that accepts every word in L and either rejects or loops for every word that
is not in L. The language L is
a) NP hard b)NP complete c)recursive d)recursively enumerable
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
47
.
Consider the following statements
Recursive languages are closed under complementation
Recursively enumerable languages are closed under union
Recursively enumerable languages are closed under complementation
Which of the above statement are TRUE?
a) I only
b)I and II c)I and III d) II and III
48
.
Which of the following statement is wrong?
a) Any regular language can be generated by a context-free
grammar b)Some non-regular languages cannot be generated
by any CFG
c)the intersection of a CFL and regular set is a CFL
d)All
non-regular languages can be generated by CFGs.
49
.
Recursively enumerable languages are not closed under
a) Union
b)homomorphism c)complementation c)concatenation
50
.
Which of the following problem is undecidable?
a) membership problem for CFL
b)membership problem for regular
sets
c)membership problem for CSL
d)membership problem for type 0 languages
51
.
Recursive languages are
a) a proper superset of CFL
b)always recognized by PDA
also called type 0 languages
d)always recognized by FSA
52
.
R1 and R2 are regular sets. Which of the following is not true?
a) R1 ∩ R2 neet not be regular
b)Σ* − R1 is regular
R2 is regular
d)
c)are
c)R1 ∪
is regular
53
.
Which of the following regular expression identity is true?
a) r(*) = r*
b)(r*s*)* = (r + s)*
c)(r + s)* = r* + s*
d)r*s* = r* + s*
54
.
Which one of the following statement is FALSE?
a) context-free languages are closed under union
languages are closed under concatenation
c)context-free languages are closed under intersection
languages are closed under Kleene closure
b)context-free
d)context-free
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
55
.
56.
III - CSE
Which of the following conversion is not possible (algorithmically)?
a) regular grammar to context-free grammar
b)nondeterministic FSA to deterministic FSA
c)nondeterministic PDA to deterministic PDA
d)nondeterministic TM to deterministic TM
Palindromes can’t be recognized by any FSA because
a) FSA cannot remember arbitrarily large amount of information b)FSA cannot
deterministically fix the midpoint
c)Even if the mid point is known an FSA cannot find whether the second half of the
string matches the first half
d)all of the above
57.
Let Σ = {a, b, c, d, e}. The number of strings in Σ* of length 4 such that no symbol is
used more than once in a string is
a) 360
b)120 c)35 d)36
58.
Which of the following denotes Chomskian hiearchy?
a) REG ⊂ CFL ⊂ CSL ⊂ type0 b)CFL ⊂ REG ⊂ type0 ⊂ CSL
REG ⊂ CFL d)CSL ⊂ CFL ⊂ REG ⊂ type0
c)CSL ⊂ type0 ⊂
59.
A language L is accepted by a FSA iff it is
a) CFL b)CSL c)recursive d)regular
60.
Which of the following regular expressions denotes a language comprising of all possible
strings over Σ = {a, b} of length n where n is a multiple of 3.
a) (a + b + aa + bb + aba + bba)* b)(aaa + bbb)* c)((a + b)(a + b)(a + b))* d)(aaa
+ ab + a) + (bbb + bb + a)
61.
A language is represented by a regular expression (a)*(a + ba). Which of the following
string does not belong to the regular set represented by the above expression.
a) aaa
b)aba
c)ababa
d)aa
62.
Which of the following is not primitive recursive but partially recursive?
a) McCarthy’s function b)Riemann function c)Ackermann’s function
function
63.
d)Bounded
Consider the following right-linear grammar G = (N, T, P, S) N = {S}
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
P : S → aS|Aa T = {a, b}
A → bA|b
64.
Which of the following strings is not generated by the following grammar? S → SaSbS|ε
a) aabb
b)abab c)aababb
d)aaabb
65.
Consider the following NFSA
46
D
47
B
48
D
a) The automaton accepts b)all words of the form {(ab)na|n ≥ 1}
with a and ε d)all words that end with a and not ε
d)all words containing substring ba
c)all words that end
49 50
C D
62
C
51
A
52
A
53
B
54
C
55
C
56
D
57
B
58
A
59
D
60
C
61
C
63
C
64
D
65
C
PART-B
(2 MARKS)
66. Define parser. (A.U Nov/Dec 2008) (A.U Nov/Dec 2012)
Hierarchical analysis is one in which the tokens are grouped hierarchically into nested collections with
collective meaning. Also termed as Parsing.
67. Mention the basic issues in parsing.
There are two important issues in parsing.

Specification of syntax

Representation of input after parsing.
68. Why lexical and syntax analyzers are separated out? (A.U Nov/Dec 2007)
Reasons for separating the analysis phase into lexical and syntax analyzers:

Simpler design.

Compiler efficiency is improved.

Compiler portability is enhanced.
69. Define a context free grammar. (A.U Nov/Dec 2007)
A context free grammar G is a collection of the following

V is a set of non terminals

T is a set of terminals

S is a start symbol

P is a set of production rules
G can be represented as G = (V,T,S,P)
Production rules are given in the following form
Non terminal → (V U T)*
70. Briefly explain the concept of derivation.
Derivation from S means generation of string w from S. For constructing derivation two things are important.
1. Choice of non terminal from several others.
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
2. Choice of rule from production rules for corresponding non
Terminal.
Instead of choosing the arbitrary non terminal one can choose
1. Either leftmost derivation– leftmost non terminal in a sentinel form
2. Or rightmost derivation– rightmost non terminal in a sentinel form
71. Define ambiguous grammar. (A.U Nov/Dec 2007) (A.U May/June 2013)
A grammar G is said to be ambiguous if it generates more than one parse tree for some sentence of language
L(G).
I.e. both leftmost and rightmost derivations are same for the given sentence.
72. What is a operator precedence parser? (A.U May 2007)
A grammar is said to be operator precedence if it possess the following properties:
1. No production on the right side is ε.
2. There should not be any production rule possessing two adjacent non Terminals at the right hand side.
73. List the properties of LR parser. (A.U Nov/Dec 2007)
1. LR parsers can be constructed to recognize most of the programming Languages for which the
context free grammar can be written.
2. The class of grammar that can be parsed by LR parser is a superset of class Of grammars that can be
parsed using predictive parsers.
3. LR parsers work using non backtracking shift reduce technique yet it is efficient one.
74. Mention the types of LR parser. (A.U May 2007)
SLR parser- simple LR parser
LALR parser- look ahead LR parser
Canonical LR parser
75. What are the problems with top down parsing? (A.U May 2010)
The following are the problems associated with top down parsing:

Back t r ack i n g

Left recursion

Left factoring

Ambiguity
76. Write the algorithm for FIRST and FOLLOW. (A.U May 2007) (A.U May/June 2012)
FIRST
1. If X is terminal, then FIRST(X) IS {X}.
2. If X → ε is a production, then add ε to FIRST(X).
3. If X is non terminal and X → Y1,Y2..Yk is a production, then place a in
FIRST(X) if for some i , a is in FIRST(Yi) , and ε is in all of
FIRST (Y1),…FIRST(Yi-1);
FOLLOW
1. Place $ in FOLLOW(S), where S is the start symbol and $ is the input right
End marker.
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
2. If there is a production A → αBβ, then everything in FIRST (β) except for ε is
Placed in FOLLOW (B).
3. If there is a production A → αB, or a production A→ αBβ where FIRST(β)
Contains ε , then everything in FOLLOW(A) is in FOLLOW(B).
77. List the advantages and disadvantages of operator precedence parsing.
Advantages:
This type of parsing is simple to implement.
Disadvantages:
The operator like minus has two different precedence(unary and binary).Hence it is hard to handle tokens like
minus sign. This kind of parsing is applicable to only small class of grammars.
78. What is dangling else problem? (A.U Nov/Dec 2007)
Ambiguity can be eliminated by means of dangling-else grammar which is show below:
stmt → if expr then stmt
| if expr then stmt else stmt
| Other
79. Write short notes on YACC. (A.U May/June 2010) (A.U Nov/Dec 2012)

YACC is an automatic tool for generating the parser program.

YACC stands for Yet another Compiler Compiler which is basically the
utility available from UNIX.

Basically YACC is LALR parser generator.

It can report conflict or ambiguities in the form of error messages.
80. What is meant by handle pruning?
A rightmost derivation in reverse can be obtained by handle pruning. If w is a sentence of the grammar at hand,
then w = γn, where γn is the nth right-sentential form of some as yet unknown rightmost derivation S = γ0 =>
γ1…=> γn-1 => γn = w
81. Define LR(0) items. (A.U Nov/Dec 2011)
An LR (0) item of a grammar G is a production of G with a dot at some position of the right side. Thus,
production A → XYZ yields the four items A→.XYZ A→X.YZ A→XY.Z A→XYZ.
82. What is meant by viable prefixes?
The set of prefixes of right sentential forms that can appear on the stack of a shift- reduce parser are called
viable prefixes. An equivalent definition of a viable prefix is that it is a prefix of a right sentential form that
does not continue past the right end of the rightmost handle of that sentential form.
83. Define handle.
A handle of a string is a substring that matches the right side of a production, and whose reduction to the
nonterminal on the left side of the production represents one step along the reverse of a rightmost derivation. A
handle of a right – sentential form γ is a production A→β and a position of γ where the string β may be found
and replaced by A to produce the previous right-sentential form in a rightmost derivation of γ. That is , if S
=>αAw =>αβw,then A→β in the position following α is a handle of αβw.
84. What are kernel & non-kernel items? (A.U Nov/Dec 2011)
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
Kernel items, whish include the initial item, S'→ .S, and all items whose dots are not at the left end. Non-kernel
items, which have their dots at the left end.
85. What is phrase level error recovery? (A.U May/June 2013)
Phrase level error recovery is implemented by filling in the blank entries in the predictive parsing table with
pointers to error routines. These routines may change, insert, or delete symbols on the input and issue
appropriate error messages. They may also pop from the stack.
PART-C
(16 MARKS)
86. What is FIRST and FOLLOW? Explain in detail with an example. Write down (A.U Nov/Dec 2009)
87. Construct Predictive parsing table for the following grammar: the necessary algorithm.
S > (L)/ a
L > L, S/S and check whether the following sentences belong to that grammar or not.
(i) (a, a)
(ii) (a, (a , a))
(iii) (a,((a, a),(a, a))). (A.U Nov/Dec 2012)
88. (a) Construct the predictive parser for the following grammar: (A.U May/June 2007)
S > (L)|a L > L,S|S.
(b) Construct the behavior of the parser on sentence (a, a) using the grammar:
S > (L)|a L > L,S|S.
89. (a) Check whether the following grammar is SLR (1) or not. Explain your answer with
Reasons. (A.U Nov/Dec 2007) (A.U May/June 2013)
S> L=R S>R L>*R L>id R>L.
(b) For the grammar given below, calculate the operator precedence relation and the
Precedence functions.
E>E+E|E –E|E*E|E/E|E^E|(E)| E|id . (A.U Nov/Dec 2011) (A.U Nov/Dec 2012)
90. Check whether the following grammar is a LL (1) grammar (A.U Nov/Dec 2008)
S > iEtS | iEtSeS | a E> b Also define the FIRST and FOLLOW procedures.
91.(a) Consider the grammar given below.
E>E+T E>T T>T*F T>F F>(E)F>id. Construct an LR Parsing table for the above grammar. Give the
moves of LRn parser on id*id+id. (A.U May/June 2013)
(b) What is a shift reduce parser? Explain in detail the conflicts that may occur during shift reduce
parsing. (A.U Nov/Dec 2010) (A.U Nov/Dec 2012)
UNIT-III
PART-A
92.
INTERMEDIATE CODE GENERATION
(1 MARKS)
Which of the following CF language is inherently ambiguous?
a) {anbncmdm|n, m ≥ 1}
b){anbmcpdq|n = p or m = q, n, m, p, q ≥ 1} c){anbmcpdq|n ≠ m ∧ p
≠ q} d){anbmcpdq|n ≠ m ∨ p ≠ q}
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
93.
Which string is not accepted by the following FSA?
a) 00111 b)01010 c)00110 d)11010
94.
Which string is accepted by the following FSA?
a) 00111 b)11011 c)01101 d)0101
95.
Can a DFSA simulate a NFSA
a)No b)Yes c)sometimes d)depends on NFA
96.
Which of the following is true for an arbitrary language L.?
a) a) L* = L+ ∪ {λ} b)L* = L+ c)L* = L+ − {λ}
97.
The concept of FSA is much used in this part of the compiler
a) lexical analysis b)parser c)code generation d)code optimization
98.
The concept of grammar is much used in this part of the compiler
a) lexical analysis b)parser c)code generation d)code optimization
99.
(a + b)(cd)*(a + b) denotes the following set
a) {a(cd)nb|n ≥ 1}
b){a(cd)na|n ≥ 1} ∪ {b(cd)nb/n ≥ 1}
{b(cd)na/n ≥ 0} ∪ {b(cd)nb/n ≥ 0}
d) {acndnb|n ≥ 1}
100.
101.
baa*c denotes the set
a) {bnamcp|n, m, p ≥ 1}
b){banc|n ≥ 0}
c){a(cd)na|n ≥ 0} ∪ {a(cd)nb/n ≥ 0} ∪
c){banc|n ≥ 1}
d){w|w is a string of a, b, c}
The set of all strings over the alphabet Σ = {a, b} (including ε) is denoted by
a) (a + b)*
b) (a + b)+ c) a+b+ d) a*b*
102. The maximum degree of any vertex in a simple graph with n vertices is
(A) n–1 (B) n+1 (C) 2n–1 (D) n
103. The data structure required for Breadth First Traversal on a graph is
(A) Queue (B) stack (C) array (D) tree
104. The quick sort algorithm exploit _________ design technique
(A) Greedy (B) Dynamic programming (C) Divide and Conquer (D) Backtracking
The numbers of different directed trees with 3 nodes are
(A) 2 (B) 3 (C) 4 (D) 5
105. One can convert a binary tree into its mirror image by traversing it in
(A) in order (B) preorder (C) post order (D) any order
106. The total number of companions required to merge 4 sorted files containing 15, 3, 9 and 8records
into a single sorted file is
(A) 66 (B) 39 (C) 15 (D) 3
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
107. In a linked list with n nodes, the time taken to insert an element after an element pointed bysome
pointer is
(A) 0 (1) (B) 0 (log n)(C) 0 (n) (D) 0 (n 1og n)
108. The data structure required to evaluate a postfix expression is
(A) queue (B) stack (C) array (D) linked-list
109. The data structure required to check whether an expression contains balanced parenthesis is
(A) Stack (B) Queue (C) Tree (D) Array
110. The complexity of searching an element from a set of n elements using Binary search
algorithm is
(A) O(n) (B) O(log n) (C) O(n2) (D) O(n log n)
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
B A B B B A B C C
A
A
A
C
B
C
D
A
B
A
PART-B
(2 MARKS)
111. What are the benefits of intermediate code generation? (A.U May 2008)
A Compiler for different machines can be created by attaching different back end to the existing front ends of
each machine. A Compiler for different source languages can be created by proving different front ends for
corresponding source languages t existing back end. A machine independent code optimizer can be applied to
intermediate code in order to optimize the code generation.
112. What are the various types of intermediate code representation? (A.U Nov/Dec 2007)
There are mainly three types of intermediate code representations.
 Syntax tree
 Postfix
 Three address code
113. Define back patching. (A.U Nov/Dec 2009) (A.U Nov/Dec 2010) (A.U May/June 2013)
Back patching is the activity of filling up unspecified information of labels using appropriate semantic actions
in during the code generation process. In the semantic actions the functions used are mklist (i), merge
list(p1,p2) and back patch(p,i)
114. Mention the functions that are used in back patching. (A.U Nov/Dec 2007)
(i) Creates the new list. The index i is passed as an argument to this function where I is an index to the array of
quadruple.
(ii) Merge list (p1, p2) this function concatenates two lists pointed by p1 and p2. It returns the pointer to the
concatenated list.
(iii) Back patch (p, i) inserts i as target label for the statement pointed by pointer p.
115. What is the intermediate code representation for the expression a or b
And not c? (A.U May/June 2013)
The intermediate code representation for the expression a or b and not c is the three address sequence
t1 := not c
t2 := b and t1
t3 := a or t2
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
116. What are the various methods of implementing three address statements?
The three address statements can be implemented using the following methods.
 Quadruple: a structure with at most four fields such as operator (OP), arg1, arg2, result.
 Triples: the use of temporary variables is avoided by referring the pointers in the
symbol table.
 Indirect triples: the listing of triples has been done and listing pointers are used instead of
using statements.
117. Give the syntax-directed definition for if-else statement. (A.U May/june 2008)
1 . S → if E then S1
E.true := new_label()
E.false :=S.next
S1.next :=S.next
S.code :=E.code | | gen_code(E.true „: „) | | S1.code
2.
S → if E then S1 else S2
E.true := new_label()
E.false := new_label()
S1.next :=S.next
S2.next :=S.next
S.code :=E.code | | gen_code(E.true „: „) | | S1.code| | gen_code(„go
to‟,S.next) | |gen_code(E.false „:‟) | | S2.code
118. What are the methods to represent the value of a Boolean expression?

Numerical representation

Encode true and false. Numerically and to evaluate a Boolean expression analogously to an
arithmetic expression.

Flow of Control Implementing Boolean expression is by flow of control i.e., representing the
value of a Boolean expression by a position reached in a program.
119. Define short-circuit code. (A.U May/June 2008)
It translates a Boolean expression into three address code without generating code for any of the
Boolean operators and without having the code necessarily evaluates the entire expression. This type of
evaluation is called short circuit or jumping code.
120. Define Boolean expression.
Boolean expressions are composed of the Boolean operators (and,or, not) applied to elements. Those are
Boolean variables or relational expressions.
121. Define three address codes. (A.U Nov/Dec 2010)
Three address code is a sequence of statements of the general form
x: = y op z
where x,y,z are operand and op is operator.
122. Write the properties of intermediate languages.

The intermediate language is an easy form of source language which
Can be generated efficiently by the compiler.
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE


The generation of intermediate language should lead to efficient code Generation.
The intermediate language should act as effective mediator between
Front and back end.

The intermediate language should be flexible enough so that optimized
Code can be generated.
123. Generate the three address code for an expression x: = a + b * c +d ;
Assuming x and a as real and b,c and d are integer.
t1 := b int * c
t2 := t1 int + d
t3 := inttoreal t2
t4 := a real + t3
x := t4
124. Generate the three address code for
while (i<10)
{x := 0; i := i + 1;
}
The three address code can be generated as follows
100
L1 : if i<10 goto L2
101
Goto Lnext
102
L2 : x = 0
103
i =i +1
104
goto L1
105
Lnext
125. Write the translation scheme for
while (i<10)
{x := 0; i := i + 1;
}S.begin = new_label() = L1
E.true = new_label() = L2
E.code = “if i<10 goto”
E.false = S.next = Lnext
S1.code = x =0; i = i + 1
Generate the three address code for
switch (ch)
{case 1: c := a + b; break;
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
case 2: c := a– b; break;
}The three address code can be generated as follows
100
if ch = 1 goto L1
101
if ch = 2 goto L2
102
L1: t1 := a + b
103
c := t1
104
goto Last
105
L2 : t1 : = a - b
106
c := t1
107
goto Last
108
Last:
126. Write the translation scheme for
switch (ch)
{case 1: c := a + b; break;
case 2: c := a– b; break;
}Evaluate E into t such that t = E
Goto check
L1 : code for s1
goto last
L2 : code for s2
goto last
check : if c = a + b goto L1
if c = a– b goto L2
last:
127. Write the semantic action for the production rule of E E1 OR M E2.
{Backpatch (E1.Flist, M.state);
E.Tlist := merge ( E1.Tlist,E2.Tlist);
E.Flist := E2.Flist
}
128. Write the semantic action for the production rule of S call id (L).
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
{for each item p in queue do
append („param‟ p);
append („call‟ id.place
}
129. Write the semantic action for the production rule of L. L, E.
{insert E.place in the queue
}
130. Write the semantic action for the production rule of L. E (A.U Nov/Dec 2007)
{initialize queue and insert
E.place in the queue }
PART-C
(16 MARKS)
131. How would you generate the intermediate code for the flow of control statements? Explain with
examples. (A.U Nov/Dec 2011) (A.U Nov/Dec 2012)
132. a)What are the various ways of calling procedures? Explain in detail. (A.U Nov/Dec 2007)
(b)What is a three address code? Mention its types. How would you implement the three address
statements? Explain with examples. (A.U Nov/Dec 2009)
133. How would you generate intermediate code for the flow of control statements?
Explain with examples. (A.U Nov/Dec 2010) (A.U May/June 2013)
134. (a)Describe the method of generating syntax directed definition for
Control statements. (A.U Nov/Dec 2008) (A.U May/June 2013)
(b)Give the semantic rules for declarations in a procedure. (8) (A.U May/June 2013)
135. (a) How Back patching can be used the generate code for Boolean expressions and flow of control
statements. (A.U Nov/Dec 2007)
(b)Explain how the types and relative addresses of declared names are computed and how scope
information is dealt with. (8) (A.U Nov/Dec 2011)
136.(a) Describe in detail the syntax directed translation of case statements.
(b) Explain in detail the translation of assignment statements. (8) (A.U Nov/Dec 2011) (A.U Nov/Dec
2012)
UNIT-IV
CODE GENERATION
PART-A
(1 MARKS)
137.
Palindromes can’t be recognized by any FSA because
a) FSA cannot remember arbitrarily large amount of information
b)FSA cannot deterministically fix the midpoint
c)Even if the mid point is known an FSA cannot find whether the second half of the string
matches the first half
d)all of the above
138.
Let Σ = {a, b, c, d, e}. The number of strings in Σ* of length 4 such that no symbol is used more
than once in a string is
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
a) 360
139.
III - CSE
b)120 c)35 d)36
Which of the following denotes Chomskian hiearchy?
a)REG ⊂ CFL ⊂ CSL ⊂ type0 b)CFL ⊂ REG ⊂ type0 ⊂ CSL
d)CSL ⊂ CFL ⊂ REG ⊂ type0
c)CSL ⊂ type0 ⊂ REG ⊂ CFL
140.
A language L is accepted by a FSA iff it is
a)CFL b)CSL c)recursive d)regular
141.
Which of the following regular expressions denotes a language comprising of all possible strings
over Σ = {a, b} of length n where n is a multiple of 3.
a)(a + b + aa + bb + aba + bba)* b)(aaa + bbb)* c)((a + b)(a + b)(a + b))* d)(aaa + ab +
a) + (bbb + bb + a)
142.
A language is represented by a regular expression (a)*(a + ba). Which of the following string does
not belong to the regular set represented by the above expression.
a)aaa
b)aba
c)ababa
d)aa
143.
Which of the following is not primitive recursive but partially recursive?
a)McCarthy’s function b)Riemann function c)Ackermann’s function d)Bounded function
144.
Consider the following right-linear grammar G = (N, T, P, S) N = {S}
P : S → aS|aA T = {a, b}
A → bA|b
Which of the following regular expression denotes L(G)?
a)(a + b)* b)a(ab)*b c)aa*bb* d)a*b*
145.
Which of the following strings is not generated by the following grammar? S → SaSbS|ε
a)aabb
b)abab c)aababb
d)aaabb
146.
Consider the following NFSA
a)The automaton accepts b)all words of the form {(ab)na|n ≥ 1}
d)all words that end with a and not ε
d)all words containing substring ba
c)all words that end with a and ε
147. The number of leaf nodes in a complete binary tree of depth d is
(A) 2d (B) 2d–1+1 (C) 2d+1+1 (D) 2d+1
148. What data structure would you mostly likely see in a nonrecursive implementation of a recursive
algorithm?
(A) Stack (B) Linked list (C) Queue (D) Trees
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
149. Which of the following sorting methods would be most suitable for sorting a list which isalmost
sorted
(A) Bubble Sort (B) Insertion Sort (C) Selection Sort (D) Quick Sort
150. A B-tree of minimum degree t can maximum _____ pointers in a node.
(A) t–1 (B) 2t–1 (C) 2t (D) t
151. The process of accessing data stored in a serial access memory is similar to manipulating data on a
(A) Heap (B) queue (C) stack (D) binary tree
152. A graph with n vertices will definitely have a parallel edge or self loop if the total number of edges is
(A) Greater than n–1 (B) less than n(n–1) (C) greater than n(n–1)/2 (D) less than n2/2
153. a BST is traversed in the following order recursively: Right, root, left
The output sequence will be in
(A) Ascending order (B) Descending order (C) Bitomic sequence (D) No specific order
154. The pre-order and post order traversal of a Binary Tree generates the same output. The tree can
have maximum
(A) Three nodes (B) Two nodes (C) One node (D) Any number of nodes
155. The postfix form of A*B+C/D is
(A) *AB/CD+ (B) AB*CD/+
(C) A*BC+/D
(D) ABCD+/*
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
D
B
A
D
C
C
C
C
D
C
A
A
A
D
C
A
B
B
B
PART-B
(2 MARKS)
156. Mention the properties that a code generator should possess. (A.U Nov/Dec 2007)

The code generator should produce the correct and high quality code. In other words, the code
generated should be such that it should make effective use of the resources of the target machine.
 Code generator should run efficiently.
157. List the terminologies used in basic blocks. (A.U Nov/Dec 2009)
 Define and use– the three address statement a:=b+c is said to define a and to use b and c.
 Live and dead– the name in the basic block is said to be live at a given point if its value is used
after that point in the program. And the name in the basic block is said to be dead at a given point if
its value is never used after that point in the program.
158. What is a flow graph? (A.U Nov/Dec 2008) (A.U May/June 2013)
A flow graph is a directed graph in which the flow control information is added to the basic blocks.
 The nodes to the flow graph are represented by basic blocks
 The block whose leader is the first statement is called initial block.
 There is a directed edge from block B1 to block B2 if B2 immediately follows B1 in the given
sequence. We can say that B1 is a predecessor of B2.
159. What is a DAG? Mention its applications. (A.U May/June 2007) (A.U Nov/Dec 2012)
Directed acyclic graph(DAG) is a useful data structure for implementing
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
Transformations on basic blocks.
DAG is used in
 Determining the common sub-expressions.
 Determining which names are used inside the block and computed outside the block.
 Determining which statements of the block could have their computed value outside the block.
 Simplifying the list of quadruples by eliminating the common su-expressions and not performing the
assignment of the form x := y unless and until it is a must.
160. Define peephole optimization. (A.U May/June 2008)
Peephole optimization is a simple and effective technique for locally improving target code. This
technique is applied to improve the performance of the target program by examining the short sequence of
target instructions and replacing these instructions by shorter or faster sequence.
161. List the characteristics of peephole optimization. (A.U Nov/Dec 2011)
 Redundant instruction elimination
 Flow of control optimization
 Algebraic simplification
 Use of machine idioms
162. How do you calculate the cost of an instruction?
The cost of an instruction can be computed as one plus cost associated with the source and destination
addressing modes given by added cost.
MOV R0,R1 1
MOV R1,M 2
SUB 5(R0),*10(R1) 3
163. What is a basic block? (A.U Nov/Dec 2010)
A basic block is a sequence of consecutive statements in which flow of control enters at the
beginning and leaves at the end without halt or possibility of branching.
Eg. t1:=a*5
t2:=t1+7
t3:=t2-5
t4:=t1+t3
t5:=t2+b
164. How do you calculate the cost of an instruction?
The instruction cost can be computed as one plus cost associated with the source and destination
addressing modes given by “added cost”.
This cost corresponds to the length of the instruction.
e.g.
Instruction
Cost
Interpretation
MOV R0,R1
1
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
Cost of register mode +1 =
0+1=1
MOV R1,M
2
Use of memory variable +1
=1+1=2
SUB 5(R0),*10(R1)
3
Use of first constant + use of
second constant +1 = 3
165. Compute the cost of following set of instructions. (A.U Nov/Dec 2007)
MOV a, R0
ADD b, R0
MOV R0, c
MOV a, R0
2
ADD b, R0
2
MOV R0, c
2 ----- Total Cost
166. Define code generation. (A.U Nov/Dec 2012)
The code generation is the final phase of the compiler. It takes an intermediate representation of
the source program as the input and produces an equivalent target program as the output.
167. Define Target machine.
The target computer is byte addressable machine with four bytes to a word and n general purpose
registers, R0,R1,……Rn-1. It has two address instructions of the form.Op source, destination
168. What is register descriptor
A register descriptor is a pointer to a list containing information about the current contents of each
register. Initially all the register are empty.
169. What is address descriptor?
An address descriptor keeps track of the location where the current value of the name can be found at
run time. This information can be stored in the symbol table.
170. Define common subexpression elimination.
An expression E is called a common subexpression if E was previously computed and the values of
variables in E have not changed.
171. Define dead code. (Nov/Dec 2007)
A variable is live at a point in a basic block, if its value can be used subsequently. Otherwise, it is dead
at that point.
172. List out the common issues in the design of code generator.
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
 Input to the code generator
 Target program
 Memory Management
 Instruction selection
 Register allocation
 Choice of evaluation order and
 Approaches to code generation.
173. Generate a code for following statements
a = b + c;
d =a+e
The Code will be
MOV b, R0 ADD c, R0 MOV R0, a
PART-C
(16 MARKS)
174.(a) Explain the issues in design of code generator. (A.U Nov/Dec 2007) (A.U May 2012)
(b)Explain peephole optimization. (A.U May/June 2011) (A.U Nov/Dec 2011)
175.(a) Discuss run time storage management of a code generator. (A.U Nov/Dec 2008)
(b)Explain DAG representation of the basic blocks with an example. (A.U May 2013)
176.(a) Explain the simple code generator with a suitable example. (A.U Nov/Dec 2009)
(b)Describe about the stack allocation in memory management. (A.U May/June 2012)
177.(a) what are the different storage allocation strategies? (A.U May 2009)
(b)What are steps needed to compute the next use information?
178.(a) Write detailed notes on Basic blocks and flow graphs.
(A.U May 2011) (A.U May/June 2013)
(b)How would you construct a DAG for a Basic block? Explain with an example.
(A.U Nov/Dec 2007) (A.U May/June 2013)
UNIT-V CODEOPTIMIZATIONANDRUNTIMEENVIRONMENTS
PART-A
(1 MARKS)
179.
Which of the following CF language is inherently ambiguous?
a){anbncmdm|n, m ≥ 1}
b){anbmcpdq|n = p or m = q, n, m, p, q ≥ 1} c){anbmcpdq|n ≠ m ∧ p ≠
q} d){anbmcpdq|n ≠ m ∨ p ≠ q}
180.
Which string is not accepted by the following FSA?
a)00111 b)01010 c)00110 d)11010
181.
Which string is accepted by the following FSA?
a) 00111 b)11011 c)01101 d)0101
182.
Can a DFSA simulate a NFSA
a)No b)Yes c)sometimes d)depends on NFA
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
183.
Which of the following is true for an arbitrary language L.
a) L* = L+ ∪ {λ} b)L* = L+ c)L* = L+ − {λ}
184.
The concept of FSA is much used in this part of the compiler
a)lexical analysis b)parser c)code generation d)code optimization
185.
The concept of grammar is much used in this part of the compiler
a)lexical analysis b)parser c)code generation d)code optimization
186.
(a + b)(cd)*(a + b) denotes the following set
a) {a(cd)nb|n ≥ 1}
b){a(cd)na|n ≥ 1} ∪ {b(cd)nb/n ≥ 1}
{b(cd)na/n ≥ 0} ∪ {b(cd)nb/n ≥ 0}
d) {acndnb|n ≥ 1}
187.
188.
baa*c denotes the set
a){bnamcp|n, m, p ≥ 1}
b){banc|n ≥ 0}
c){a(cd)na|n ≥ 0} ∪ {a(cd)nb/n ≥ 0} ∪
c){banc|n ≥ 1}
d){w|w is a string of a, b, c}
The set of all strings over the alphabet Σ = {a, b} (including ε) is denoted by
a)(a + b)* b) (a + b)+ c) a+b+ d) a*b*
189. The maximum degree of any vertex in a simple graph with n vertices is
(A) n–1
(B) n+1
(C) 2n–1
(D) n
190. The data structure required for Breadth First Traversal on a graph is
(A) queue
(B) stack
(C) array
(D) tree
191. The quick sort algorithm exploit _________ design technique
(A) Greedy (B) Dynamic programming
(C) Divide and Conquer (D) Backtracking
The number of different directed trees with 3 nodes are
(A) 2 (B) 3 (C) 4 (D) 5
192. One can convert a binary tree into its mirror image by traversing it in
(A) inorder (B) preorder (C) postorder
(D) any order
193. The total number of companions required to merge 4 sorted files containing 15, 3, 9 and 8 records into a
single sorted file is
(A) 66
(B) 39
(C) 15
(D) 3
194. In a linked list with n nodes, the time taken to insert an element after an element pointed by some pointer
is
(A) 0 (1) (B) 0 (log n)(C) 0 (n) (D) 0 (n 1og n)
195. The data structure required to evaluate a postfix expression is
(A) queue
(B) stack
(C) array
(D) linked-list
196. The data structure required to check whether an expression contains balanced parenthesis is
(A) Stack
(B) Queue
(C) Tree
(D) Array
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
197. The complexity of searching an element from a set of n elements using Binary search
algorithm is
(A) O(n)
(B) O(log n) (C) O(n2)
(D) O(n log n)
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
B
A
B
B
B
A
B
C
C
A
A
A
C
B
C
D
A
B
A
PART-B
(2 MARKS)
198. Mention the issues to be considered while applying the techniques for code optimization.
 The semantic equivalence of the source program must not be changed.
 The improvement over the program efficiency must be achieved without changing the algorithm of
the program.
199. What are the basic goals of code movement? (A.U Nov/Dec 2007) (A.U May 2013)
 To reduce the size of the code i.e. to obtain the space complexity.
 To reduce the frequency of execution of code i.e. to obtain the time complexity.
200. What do you mean by machine dependent and machine independent optimization?
 The machine dependent optimization is based on the characteristics of the target machine for the
instruction set used and addressing modes used for the instructions to produce the efficient target code.
 The machine independent optimization is based on the characteristics of the programming languages
for appropriate programming structure and usage of efficient arithmetic properties in order to reduce the
execution time.
201.What are the different data flow properties? (A.U Nov/Dec 2008)
 Available expressions
 Reaching definitions
 Busy variables
202. List the different storage allocation strategies. (A.U Nov/Dec 2007)
The strategies are:

Static allocation

Stack allocation

Heap allocation
203. What are the contents of activation record? (A.U May/June 2007)
The activation record is a block of memory used for managing the information needed by a single
execution of a procedure. Various fields of activation record are:

Temporary variables

Local variables

Saved machine registers

Control link

Access link

Actual parameters

Return values
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
204. What is dynamic scoping?
In dynamic scoping a use of non-local variable refers to the non-local data declared in most
recently called and still active procedure. Therefore each time new findings are set up for local names
called procedure. In dynamic scoping symbol tables can be required at run time.
205. Define symbol table. (A.U Nov/Dec 2007) (A.U Nov/Dec 2010) (A.U May/June 2013)
Symbol table is a data structure used by the compiler to keep track of semantics of the variables.
It stores information about scope and binding information about names.
206. What is code motion? (A.U May/June 2012)
Code motion is an optimization technique in which amount of code in a loop is decreased. This
transformation is applicable to the expression that yields the same result independent of the number of
times the loop is executed. Such an expression is placed before the loop.
207. What are the properties of optimizing compiler? (A.U Nov/Dec 2007)
The source code should be such that it should produce minimum amount of target code. There
should not be any unreachable code. Dead code should be completely removed from source language.
The optimizing compilers should apply following code improving transformations on source language.
 common subexpression elimination
 dead code elimination

code movement

strength reduction
208. What are the various ways to pass a parameter in a function?

Call by value

Call by reference

C o p y-r es t o r e

Call by name
209. Suggest a suitable approach for computing hash function.
Using hash function we should obtain exact locations of name in symbol table. The hash function should result
in uniform distribution of names in symbol table. The hash function should be such that there will be minimum
number of
collisions. Collision is such a situation where hash function results in same location for storing
the names.
210. What are the criteria that need to be considered while applying the code
optimization techniques? (A.U Nov/Dec 2007)
There are two important issues that need to be considered while applying the techniques for the code
optimization and those are:
The semantic equivalence of the program must not be changed. In simple words the meaning of program must
not be changed.
The improvement over the program efficiency must be achieved without changing the algorithm of the
program.
211. Give the criteria for achieving machine dependent optimization.
Allocation of sufficient number of resources to improve the execution efficiency of the program.
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE
QUESTION BANK
III - CSE
Using immediate instructions wherever necessary. The use of intermix instructions. The intermixing of
instructions along with the data increases the speed of execution.
212. Give the primary structure preserving transformations on basic blocks.
 Common subexpression elimination
 Copy propagation
 Dead– code elimination
 Constant folding.
213. How to store names in symbol table?
 Fixed length name– A fixed space for each name is allocated in symbol table. In this type of storage if
name is too small then there is wastage of space.
 Variable length name– The amount of space required by string is used to store the names. The name
can be stored with help of starting index and length of the each name.
214. Give the requirements for symbol table management. (A.U Nov/Dec 2011)

For quick insertion of identifier and related information.

For quick searching of identifier.
PART-C
(16 MARKS)
215. (a) Explain the principle sources of optimization in detail. (8) (A.U May/June 2013)
(b)What are the various ways of calling procedures? (A.U Nov/Dec 2010)
216. (a) Discuss about the following: i). Copy Propagation ii) Dead code Elimination and
iii) Code motion(A.U Nov/Dec 2011)
217. (b)Describe in detail about the stack allocation in memory management.
(A.U Nov/Dec 2010) (A.U May/June 2013)
218.(a) Write about Data flow analysis of structural programs.
(b)Describe the various storage allocation strategies. (A.U May 2007)
219.(a) Describe in detail the source language issues. (A.U Nov/Dec 2007)
(b) Explain in detail access to non local names.
220.(a) Elaborate storage organization. (A.U Nov/Dec 2009)
(b)Write detailed notes on parameter passing.
221.(a) Explain optimization of basic blocks. (A.U Nov/Dec 2011) (A.U May/June 2013)
(b) Explain the various approaches to compiler development(A.U Nov/Dec 2010) (A.U Nov/Dec 2012)
Mr.S.MUTHAMILSELVAN ASST.PROFESSOR/CSE