CD Question Bank
CD Question Bank
QUESTION BANK
(Dr. Kalyan Kumar Jena)
e. Write a regular expression for a language containing strings which end with “abb” over
Ʃ= {a,b}.
f. Construct a regular expression for the language containing all strings having any
Let G be a Context Free Grammar for which the production Rules are given below: S -> aB|bA
Drive the string aaabbabbba using the above grammar (using Left Most Derivation and Right
most
Derivation).
B-> Be|b
d. Handle pruning
A-> €
B-> €
E-> E*E
E->id
77. Write the properties of LR parser with its structure. Also explain the techniques of LR
parser.
78. Write a short note on:
a. Augmented grammar
b. Kernel items
A-> d
B-> d
T-> TF|F
F-> F*|a|b
Construct the SLR parsing table and also parse the input “a*b+a”
S->Aa|bAc|Bc|bBa
A->d
B->d
85. Write the comparison among SLR Parser, LALR parser and Canonical LR Parser.
86. What is syntax directed translation (SDD)?
87. Write short note on:
a. Synthesized attributes b.
Inherited attributes
c. Dependency graph
d. Evaluation order
88. Draw the syntax tree and DAG for the following expression:
(a*b)+(c-d)*(a*b)+b
b. Polish notation
d. Backpatching
92. Construct syntax tree and postfix notation for the following expression:
(a+(b*c)^d-e/(f+g)
93. Write quadruples, triples and indirect triples for the expression:
-(a*b)+(c+d)-(a+b+c+d)
94. Write the three address statement with example for:
a. Assignment
d. Boolean expression
e. If-then-else statement
95.Write the definition of symbol table and procedure to store the names in symbol table.
96.What are the data structures used in symbol table?
97.What are the limitations of stack allocation?
98.Write two important points about heap management.
99.Write the comparison among Static allocation, Stack allocation and Heap Allocation with their
merits and limitations.
100. What is activation record? Write the various fields of Activation Record.
101. What are the functions of error handler?
102. Write a short note on Error Detection and Recovery.
103. Classify the errors and discuss the errors in each phase of Compiler.
104. What are the properties of code generation phase? Also explain the Design Issues of this
phase.
105. What are basic blocks? Write the algorithm for partitioning into Blocks.
106. Write a short note on:
b. Dominators
c. Natural loops
d. Inner loops
code: Prod=0;
I=1; Do{
Prod=prod+a[i]*b[i]; I=i+1;
}while (i<=10);
b. Variable elimination
c. Code motion
d. Reduction in strength
111. What is control and data flow analysis? Explain with example.
117. What are the possible error recovery actions in lexical Analyzer?
118. What are the three general approaches to the implementation of a Lexical Analyzer?
iii. Interpreters
constructing a compiler?
132. (a)What is a compiler? Explain the various phases of compiler in detail, with a neat sketch.
133. (b) Elaborate on grouping of phases in a compiler.(6)
134. (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. (8)
135. (b) What are the phases of the compiler? Explain the phases in detail. Write down the output of
each phase for the expression a: = b +c * 50. (8)
136. Draw a NFA for a*|b*.
137. What do you mean by Handle Pruning?
138. Define LR (0) items.
139. What do you mean by viable prefixes?
140. Define handle.
141. What are the algebraic properties of regular expressions?
142. What is finite automata?
143. What are the goals of error handler in a parser?
144. What is an ambiguous grammar? Give an example.
145. .What is phrase level error recovery?
146. What are the disadvantages of operator precedence parsing?
147. What is a predictive parser?
148. Eliminate left recursion from the following grammar A->Ac/Aad/bd/c.
149. What is LL (1) grammar? Give the properties of LL (1) grammar.
150. Give the algorithm for Left Factoring a Grammar.
151. What is Left Recursion? Give an example for eliminating the same.
152. What is FIRST and FOLLOW? Explain in detail with an example. Write
S->(L)/a
L> L, S/S
and check whether the following sentences belong to that grammar or not.
(i) (a,a)
(iii) (a,((a,a),(a,a)))
(b) Construct the behaviour of the parser on sentence (a, a) using the grammar: S >
155. 4. (a) Check whether the following grammar is SLR (1) or not. Explain your answer with reasons.
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
F>(E)
F>id. Construct an LR Parsing table for the above grammar. Give the moves of LR
parser on id*id+id.
(b) What is a shiftreduce parser? Explain in detail the conflicts that may occur during shiftreduce parsing. (4)
158. How would you represent the following equation using the
159. What is the intermediate code representation for the expression a or b and not c ?
160. How would you map names to Values?
161. What are the various methods of implementing three address statements?
162. Suggest a Suitable approach for completing hash function.
163. What are the methods of representing a syntax tree?
164. Give the Syntax directed definition of if else statement.
165. What is back patching?
166. What are the applications of DAG?
167. Define marker non terminals with an example.
168. Why are quadruples preferred over triples in an optimizing Complier?
169. Give the triple representation of a ternary operation x:= y[i]
170. Give the Semantic rules for the production S _ while E do S1.
171. Let A be a 10x20 array with low1=low2=1. Therefore n1=10 and n2=20.
Take w to be 4. Give the annotated parse tree for the assignment x:=A[y,z]
174. (a)What are the various ways of calling procedures? Explain in detail.
(b)What is a three address code? Mention its types. How would you implement
175. How would you generate intermediate code for the flow of control statements? Explain with examples.
176. (a)Describe the method of generating syntax directed definition for
Control statements.
177. 5. (a) How Back patching can be used the generate code for Boolean expressions and flow of
control statements.
(b)Explain how the types and relative addresses of declared names are computed and how scope
information is dealt with.
statements.
basic blocks?
generator.
example.
197. (a)Explain the simple code generator with a suitable example.
management.
199. (a) Write detailed notes on Basic blocks and flow graphs.
(b)How would you construct a DAG for a Basic block? Explain with an example.
detail.
iii)Code motion
memory management.
analysis of structural
programs.
issues.