Dr Ambedkar Institute of Technology
Department of Computer Science and Engineering
Subject Title : Automata Theory and Introduction to compilers
Subject Code: 21CST501
No. of Credits: 3 = 2 : 1 : 0 (L-T-P)
No. of lecture hours /week : 4
Exam Duration : 3 hours
CIE +Assignment + SEE = 45 +5+50=100
Total No. of Contact Hours : 52
Subject Faculty: MEGHA L
Assistant Professor, Dept. Of CSE, Dr. AIT
Question Bank
Module -3
Context-Free Grammars and Languages
1. State and prove Pumping Lemma for CFLs. (8marks)
2. Define the following terms with examples
1.Parse tree
2.Ambiguity
3.Rightmost derivation
4. Context free grammar (CFG) (10marks)
3. Write CFG for the language
1.L = { 0n 1n | n>=1}
2. L = {w wR | w ε{a,b}*, wR is the reversal of w}
(6marks)
4. Write context free grammars for the following
i) L(G) = {a n b m c m d n : m, n ≥ 1}
ii) L(G) = { a n b n+1 : n ≥ 0 }
iii) L(G) = {w: na(w) = nb(w)}
iv) L(G) = {w: na(w) > nb(w)} (12marks)
5. Show that the following grammar is ambiguous.
S->AB | C
A->aAb | ab
B->cBd | cd
C-> aCd | aDd
D->bDc | bc
For the string “ aabbccdd” has two leftmost
derivations(10marks)
6. Consider the grammar
S-> SbS | a
The above grammar is ambiguous, show in particular
that the string “abababa” has two
(a) parse tree
(b) leftmost derivations
(c) Right most derivations
(12marks)
7. The following grammar generates prefix expressions
with operands x and y and binary operators +, -, and *
E-> + EE | *EE | -EE | x | y
(a) find LMD and RMD, and a derivation tree for the
string “+*-xyxy”
(b) prove that the grammar is unambiguous.(12marks)
8. The following grammar generates the grammar of the
language consisting of all strings of even length:
S-> AS | €
A-> aa | ab | ba | bb
Give the LMD and RMD for the following strings:
(a) aabbba
(b) baabab
(c) aaabbb (12 marks)
9. Consider the CFG , G defined by productions:
S-> aSbS | bSaS | €
Prove that L(G) is the set of all strings with equal
number of a’s and b’s (8marks)
10. Show that following grammar is ambiguous. Obtain
unambiguous grammar for this: E->E+E | E*E | E | E-E |
(E) | a | b. (6 marks)
MODULE – 5
Introduction to Compiler Design and Lexical
Analyzer
1. Explain various phases of compiler. Show the
translation for an Assignment statement.
Position= Initial + rate * 60.
Clearly indicate the output of each phase. (12marks)
2. Define the following
(a) compiler
(b) Interpreter
(c) Assembler
(d) Preprocessor (8marks)
3. Differentiate between compiler and Interpreter
(4marks)
4. With a neat diagram, explain a typical language
processing system. (6marks)
5. Explain the structure of compiler with a neat diagram.
(8marks)
6. Explain the need for intermidiate code generation and
code optimization phases in the design of a compiler.
(6marks)
7. Write a note on compiler construction tools. (6marks)
8. List and explain the applications of compiler.
(12marks)
9. write a note on Environments and states. (6 marks)
10. Differentiate between static scope and dynamic
scope, with an example. (8marks)
11. Explain parameter passing mechanisms in detail.
(6marks)
12. write a note on Aliasing. (4marks)
13. with a neat block diagram, explain the role of lexical
Analyzer. (8marks)
14. Define the following terms with an example
(a) Token
(b) patterns
(c) Lexemes (6marks)
15. Explain the concept of input buffering in lexical
analysis with its implementation. (8marks)
16. Explain Specification of tokens with an example.
(8marks)
17. Explain the concept Recognition of Tokens with an
example. (8marks)