We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 17
2)
COs | cL
MODULE-1
Introduction to Automata Theory and Compiler Design
Define the following with example: cory 2
1) Alphabet) Language) Symbol iv) Replication
v) String ~ vi) Power ofan alphabet vii) Cancatenation
vill) Proper substring — ix) Languages ~ =
Why to study Automata Theory? What are the applications of Automata Theory? con
With neat diagram, explain a hierarchy of language dasses in automata theory. co1
Bulld DFA for the following languages. con
1) Le{ we (ab)': Every ain w is immediately followed by b)
2) Le{ w e(ab)*: wot ending with “bab’} I
3) _L= {we {a by": wenntains no more than one b. more toys uta
4) Le{ we (ab)": wnet ending with “abb" Legledou
5) L={we(0,1)": whas "001" as a substring} DESMO —
6) L={w(ab+ba)|we(ady} :
7) L={ we (aby: w contains an even number of a's and odd number of b's}. show
thatthe string aabaa is accepted.
Ome
8) L={w, where }w| mod 3=0, where Y ={a}}
9) Le{we(aby’: everyregion of ‘x’ in wis of odd length}
10) Le{w (aby: every region of inwis evenength} = (2) eb
11) L={ we (aby: fw] mod 2 <|w{ med 3} :
12) Decimal strings which are divisible by 3. _
13) L={we (ab): Notwo consecutive characters are same}.
14) L={w: 8gW mod 3 = 0 and #}W mod 2 =1} where we(aby’.
Aiso write the transition table for DFA and describe quintuple values of the machine.
co1Automata Theory & Compiler Design (21CS51)
1) Construct an NFA to recognize the following keywords: 101,011, and 0101. coi | 13
7. | 2) 41) Obtain an NFA for the language: L = {w| w€ abab* or aba" Where 2520.
3) Construct an NFA to recognize the following keywords: abc abd. andaacd. ~~
con
9. | Demonstrate an algorithm for conversion from NFA to DFA. con
10. | Writean algorithm to convert the e-NFA to DFA.
11, | Construct ap equivalent DFA from the fallowing, Se wg a COr
method. Show all the steps.
a
cy
Be +O
hogs Biase
2 Caavart he Flowing EA to DFA walg subset constrain method. OF OrConstrud an | COL
equivaleot DFA from the following given NFA using subset construction method.
13, | Bulld the equivalent DFA for the following NFA by showing the value of ECOSURE(q)| C01
for each state of q.
y.. | Convert the following NFA to DFA using subset construction method. Or Construct ap
AeD ea
equivalent DFA from the following given NFA using subset construction method.
2
sear QO on ot
=
col
Bulld the equivalent DFA for the following NFA by showing the value of ECOSURE (4)
for each state of g.
y
co1
om14. | 1) Define distinguishable and indistinguishable states. Mini mite the fallowing
DFA.14, | 1 Deine distinguishable and indistinguishable states. Minimize the fallowing | |
DFA.
x _
| Menta
Totes 44
Start state: A
i Draw the table of distinguishable and indistinguishable states for an
automaton.
ii) Construct minimum state equivalent of DFA{* Table filing method)
2)MODULE-2
Regular Expressions
Define Regular Expression. Write down the applications of RE. “~~
Write the RE. far the following languages.
1) Le(w apy
2) Lefa™b
3) L= {ab
D_L-{ ww] mod = Owhere w € (ab)'}( or|w]iseven)Automata | heory & \-omipuer Design (et 2!)
—_—
3) Language of all strings of 0's and 1's that have odd number of 1's.
9) Language of all strings of O's and 1's that has at least one pair of
canseautive 0's.
10) Language of all strings of 0's and 1’s that hasno pair of consecutive 0's.
11) All strings containing exactly one ‘a’, Z=(ab,<} (or at most one a)
12) All strings containing no more than 3 a's, 5={a.bc}
13) All strings that contain at least ane occurrence of each symbol in,
T={abcj
Regular Expressions (RE) and Languages
3. | Construct the RE for the following FA using state elimination coz] Li) eM
method.1)
2 8 ° 1
mt? oa P
q a r
'r r qa
3
Gi
4)
a
7 e >
1 “ee?
AO
5)»1 (b U ab)*ab.
2 (aa'(arb))
3. (Dery 1(0+1)
Construd the following REsto FA(DFA/e NFA).
4 vor & be om
5. 10¢(011)0°1 =
Garbed
‘State and prove pumping lemma for regular languages.
‘Show that following languages are not regular
L={a"b™| n,m >0 andncm
={0"1"| n>0}
L={a"b™| n.m>0 and mm}
L={a"b™C" a" |, m>1}
L={a"| nis a perfect square
}L={a" | nis aperfect cube}
L= {ww?: w fab}}
L=(a>| ptsprime}
Li| 6M
Lexical analysis phase of compiler design
Explain the rale ofa Lexer.
12] 4M
‘Explain input buffering in detail.
iz] 6MS.10+(011)01 =
tbee
‘State and prove pumping | yr regularlanguages.( )
‘Show that following languages are nat regular
L={a"b™| n,m >0andncm
H-(0"s"| n>0) a: ¢
L-f"™[nm>oandmm} — OFA
Le{a"b™c™"'d | n, m>1}
L={a" | nis a perfect square_
}L={a" | nisaperfect cube} _—
Le {wwt:w {aby}
L={a?|pisprime}
coz | 12] om
Lexical analysis phase of compiler design_
Fa
Explain the role ofa Lexer. =~"
‘Explain input buffering in detail.
»
Explain the Specification of TokensAutomata Theory & Compiler Design (21CS51)
Question Bank —Module-3
‘Consider the grammar
3. |ESE+E/T us| am
T-F*T|F cos
F=(E)/O|t
Write the Lefamost, Right most derivation and parse mess forthe sing
0- (1+ 0)- 0).
Find the string aaabbabbba by applying left most derivation and waite the parse
tree for derivation. Is it possible to obtain the same string by applying left most
derivation but by selecting different productions?
S—aB|bA
A—aS|bAAla
B—bS |aBB|b
‘Show that the following grammar is ambiguous.
5 1) S—iCUS |5CrSeS fa
cmb
03
i) S—sbs
Sma
$ — aSbS |bSaS |e
6 | What is inherent ambiguity? Show that the given language is inherently COs
ambiguous.
L= {ambmcmnd”} n, m>=0) U {aMbMemd" | n.m>=0]
Build the non-left recursive grammar from the following left recursive grammar.
QE-E+T|T
TAT*FIF
F=(E)|id
Ut) S—AblaaA
—Ab| Saation but by selecting dillerent productions
S—-aB|bA i ae
A—aS|bAA|a Petes Nae
B—bS|aBB\b +BMD
‘Show that the following grammar is ambiguous.
1) S—iCIS |CSeS fa
cab
i) S—Sbs
S—a
S — aSbS |bSaS |e
‘What is inherent ambiguity? Show that the given language is Twherenily
ambiguous.
{afbmcd"| n, m>=0] U (ahbmemd* | w m>=0)
Build the non-left recursive grammar from the following left recursive grammar
DESE+T|T
TOT*F|F
F=(E)|id
i) S—Ablaa
= Ab| Sa
iti)S —Aalb
A—Ac|Sdle
WS—A
A— Ad] Ac|aB | ac
B—bBc|f
Define Ambiguity. Consider the
grammar E E+E |E*E|(E)|id
Find the Leftmost and Right most derivation for the string id + id * id, show
that
the grammar is ambiguous.9. | Consider the grammar Te
E—E*E|E/E cos) ts
ESE+T|E-E
E-(E|I
I —alble
Build an unambiguous grammar forthe given ambiguous grammar
1. | Find the CFG for the following languages
1) All strings over (2, b] that are even and odd palindromes. 03)
2) L=(am b2" over D= (a,b), m>=1)
3) Le(O™1M 2n an>=1 andn>=0}
4) L=(0m+21m: n>=0 and m>n)
5) L={akbm cn monck for m,
Refer Class notes for more problems.
Define Ambiguity. Consider thegrammar E -E+E|E*E|(E)|id
‘ind the Leftmost and Right mos derivation for the string id + id * id id, showthat the | cos | 13
12.
[Whats Top-Down Parsing? Explain Recursive Descent Parsing with is algorithm
‘ite the FIRST and FOLLOW fer the given grammar by making necessary changes to the glvea
Gram
E>E+T|T
TOT*FIF
F>@)Iia
Comstuct Dredictive parsing table for the following grammar.
—aABb
A-cle
Bode
[Show the parsing of the string “acdb”
MODULE
Give the formal definition of PDA. Construct a PDA to accept the following
Janguage. L= {a"b": n>=0]. Draw the transition diagram for the constructed PDA. Show
the ID's for the string aabb.
Construct a PDA to accept the following language. L= (WcWR: n>=0]. Draw the
transition diagram for the constructed PDA.
Show the ID's for the string abCba.
Define Shift Reduce Parsing. Explain its actions and Conflicts by taking an example,
4. | Find the handler for the given right sentinel form and construct the shift-reduce parsers
Given: E -E+T|T Right Sentential form: id + id * id
TOT+PIF
F—@)|id
5. (Consider the grammar
s3cc
C+ce__ MODULE4
1. | Give the formal definition of PDA. ‘Construct a PDA to accept the following
language. L= (a%b": n>=0). Draw the transition diagram for the constructed PDA. Sho
the ID's for the string aabb. bol
‘Construct a PDA to accept the following language. L= {WcWR: n>=0]. Draw the
2. | transition diagram for the constructed PDA. 4.ho>
‘Show the ID’s for the string abCba. - O' “ww:
Define Shift Reduce Parsing. Explain its actions and Conflicts by taking an example
Find the handler for the given right sentinel form and construct the shift-reduce parsers
Given: E -E+T|T Right Sentential form: id + id * id
ToT+P/F _
F-@|id
5. [Consider the grammar Se
- x
ese — CER)
cod
Construct the DFA of the sets of LR(O) items. ‘Show the parsing actions for the input string
“ccdd”. Clearly show the states and symbols on the tack.
Module - 5
‘Write the formal defimition of Turing Machine.
Explain the working of a Turing Machine with a neat diagram. Or
Explain the Turing Machine mode! with aneat diagram.Explain the extensions of Turing Machine.
Construct a Turing machine to accept L= {O*1N| n>=0). Write the transition diagram.
Show the moves made for string OI! = ae
Construct a Turing machine to accept strings formed on (0, 1] and ending with 000. Write
the transition diagram. Show the moves made for string 101000 —
Construct a Turing machine that can accept the set of all even palindromes over (0,1).
Define inherited and synthesized attributes. Give examples. —
Write the SDD for a simple desktop calculator.
ut
(2-4 ‘Write the 3 address code implementation for the given input: x=
ne Ene
Discuss the issues in the design of a code generator
arbre,