ATCD Important Questions
ATCD Important Questions
1 . Consider the context free grammar S ->SS+ | SS* | a and the string
aa+a*
i) Give the leftmost derivation for the string.
ii) Give the rightmost derivation for the string.
iii) Parse tree for the string.
2. What is the Chomsky’s hierarchical theorem? Compare context
sensitive and context free languages with suitable examples.
3. Consider the following context free grammar, G:
S ->ABAC; A -> aA |ɛ; B ->bB | ɛ ; C -> d
Convert the G equivalent to G’ that has: no null productions, and
no unit productions one after the other.
4. Let M = ({q 0 , q 1 }, {a, b}, {Z 0 , Z}, δ, q 0, Z 0, ¢ ) be a push down automata
( PDA) and δ is defined by:
δ (q 0 , b, Z 0 ) = {( q 0 , Z Z 0 )}
δ (q 0 , ε, Z 0 ) = {( q 0 , ε)}
δ (q 0 , b, X) = {( q 0 , Z Z)}
δ (q 0 , a, Z) = {( q 1 , Z)}
δ (q 1 , b, X) = {( q 1 , ε)}
δ (q 1 , a, Z 0 ) = {( q 0 , Z 0 )}
(i) Find the language accepted by the PDA, M by empty store
(ii) Construct a context free grammar (CFG), G that accepts
nullstore, N(M).
5. a) Compare deterministic PDA and non-deterministic PDA with
an example
b) Construct PDA equivalent to the following grammar:
S ->aAA; A ->aS |bS |a.
6. State and prove the pumping lemma for context free languages.
7. a) Write a context free grammar for the while statement in
C language.
b) Consider the following grammar G:
S -> ASB |ɛ;
A -> aAS |a;
B -> SbS |A |bb
Find an equivalent grammar that has: no null productions, and no
unit productions one after the other.
8. Design a PDA for L(G)={a^nb^n|n>=0}.
Unit-3
1. What is top down parsing? What are the problems in top down
parsing? Explain each with suitable example.
2. What is shift reduce parser? Consider the following grammar:
E ->E+E,E->E*E,E->(E),E-> id and show the shift-reduce parser
action for the following string id*(id+id).
3. Construct the predictive parser for the following grammar:
S->(L) |a
L->L, S|S
4. Show that the following grammar is not SLR(1)
S->AaAb |BbBa
A->ɛ
B->ɛ
5. With neat sketch explain the structure of LR parser and the rules
to compute LR item.
6, Explain with a suitable example, the techniques used in YACC to
resolve shift reduce and reduce-reduce conflicts.
7. How to construct canonical LR(1) parsing table? Construct canonical
LR(1) parsing table for the grammar,
S->CC
C->cC | d
8. Show that the following grammar
S->Aa | bAc | dc | bda
A->d
is LALR(1) but not SLR(1).
9. Explain the model and algorithm for LR parser.
10. Write a Yacc program that tells whether its input is a palindrome.
11. Explain Recursive descent parsing technique with an example.
Unit-5
1. Define DAG.
2. Write the different forms of intermediate representation.
3. What is the adress descriptor.
4. Define register descriptor.
5. Mention the different forms of Three address code.
6. what is dead code elimination.
7. What is flow graph.
8. Define basic block.
9. Mention Loop optimization techniques.
10. what is loop jamming.
1. Define quadruples and triples. Translate the expression a=b*-c+b*-c into quadruples and triples.
2. Describe DAG (directed acyclic graph) representation of basic blocks. Construct the DAG for
the following block,
d = b*c
e = a+b
b = b+c
a = e-d
3. Explain the peephole optimization in brief.
4. Explain the following,
i) Dead code elimination ii) Code Motion
5. Write about available expressions in brief.
6. What is an intermediate code? Explain different types of intermediate codes forms and denote the
subsequent statement in different forms:
W=(A+b) – (C+D) + (A+B+C).
7.Explain in brief
i) Constant folding ii) Loop unrolling iii) Strength reduction
8. Write a note on issues in code generation .
9. Explain Loop optimization tecniques in detail.
10. Explain A Simple Code Generator with an example.