0% found this document useful (0 votes)
7K views7 pages

ATCD Important Questions

The document contains details about 10 units of study related to compiler design. It includes short answer and long answer questions related to topics such as finite automata, regular expressions, context-free grammars, parsing, lexical analysis, code generation and optimization. Some key topics covered are the differences between DFAs and NFAs, regular expressions, Chomsky hierarchy, parsing techniques like LR parsing and recursive descent, phases of compilers, code representation forms like DAGs and triples, and loop optimizations. Overall, the document outlines a comprehensive syllabus for learning compiler design and implementation.

Uploaded by

bpasupul1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7K views7 pages

ATCD Important Questions

The document contains details about 10 units of study related to compiler design. It includes short answer and long answer questions related to topics such as finite automata, regular expressions, context-free grammars, parsing, lexical analysis, code generation and optimization. Some key topics covered are the differences between DFAs and NFAs, regular expressions, Chomsky hierarchy, parsing techniques like LR parsing and recursive descent, phases of compilers, code representation forms like DAGs and triples, and loop optimizations. Overall, the document outlines a comprehensive syllabus for learning compiler design and implementation.

Uploaded by

bpasupul1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Unit-1

Short Answer Questions:

1. Differences between DFA and NFA.


2. Define regular expression and regular grammar
3. Define Arden’s theorem.
4. Design DFA for string ends with 01
5. What is language? What are the operations on it?
6. What is Chomsky hierarchy?
7. Define string? What are operations on it?

Long Answer Questions:

1. a) What is a finite state machine? Compare Moore and Mealy


machines.
b) Design a Moore machine and Mealy machine that accepts strings
over ∑ = {0, 1} where, if the input ends in 001, output a A; if the
input ends in 100 , output a B; else output a C.
2. a) Draw the finite state diagram that accepts all the floating-point
Numbers.
b) Design a DFA that accepts the language over the alphabet,
Σ= {0, 1, 2} where the decimal equivalent of the language
is divisible by 3.
3. a) Convert the following ɛ-NFA to an equivalent ɛ-free NFA:

b) Construct an NFA that will accept those strings of decimal digits


that are divisible by 3.
4. a) Design a DFA that accepts the language over Σ = {0, 1} of all
strings that contain neither the sub-string 00 nor the
sub-string 11
b) Consider the following DFA, M. Let S denote the set of seven bit
binary strings in which the first, the fourth, and the last bits are 1.
What is the total number of strings in S that are accepted by M
assuming D as a final state? List all the strings.
5. Apply partition method to the following state diagram
for constructing minimal automaton.

6 a) Show that the following regular expression identities are


equivalent:
(i) r + = r * r + (ii) (r + s) * = (r + s * ) *
b) Show that the simplified regular expression recognized by the
following DFA is the set of all strings of a’s and b’s that end
with letter a.

7. Find the regular expression for the following finite automaton:


Unit-2

Short Answer Questions:

1. Define regular grammar.


2. What is ambiguous grammar? give an example
3. Write closure properties of CFL.
4. Different tuples in PDA.
5. Design of CFG.
6. Define parse tree.
7. Define LMD and RMD.
8. Different ways to simplify CFG.
9. Examples on simplification grammar.(practice)
Long Answer 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

Short Answer Questions:

1. Differences between compiler and interpreter


2. Different phases of compiler
3. Define token,pattern and lexeme
4. Define cross compiler
5. Define bootstrapping.
6. Structure of LEX.
7. Different parts of LEX.

Long Answer Questions:

1 . How to specify the tokens? Differentiate token, lexeme and


pattern with suitable examples. And draw transition diagrams also.
2. What is the role of regular expression in lexical analysis? Explain
with example.
3. What are the various phases of the compiler? Explain each phase in
detail.
4. Write the output of all phases of complier for the following expression:
x:=(a+b)*(c+d).
5. Write the output of all phases of complier for the following expression:
Intial:= Position+Rate*60.
6. Explain LEX Program with an example?
7. Write the output of all phases of complier for the following expression:
x:=i=i+70*j+2 where i and j are float values.
8. a) Define regular expressions in brief.
b) Write the regular definitions for the following languages,
i) All strings of lowercase letters that contain the five vowels in
order.
ii) All strings of digits with no repeated digits.
Unit-4

Short Answer Questions:

1. Differences between top down and bottom up parsing


2. Differences between SLR, CLR and LALR
3. Define Shift and reduce action.
4. Define augumented grammar
5. Eliminate left recursion and left factoring.(examples)
6. Structure of YACC.
7. Different parts of YACC.
8. What are the problems of top down parsing?
9. Find closure() and goto() operations for given example.

Long Answer Questions:

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

Short Answer questions:

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.

Long Answer questions:

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.

You might also like