Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
38 views10 pages

AIM3202 First Assignment

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

AIM3202 First Assignment

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

DEPARTMENT OF AIML

ASSIGNMENT QUESTIONS
Course Name: Automata Theory & Compiler Design Course Code: AIM3202
1. Construct a DFA with minimum number of states, accepting all strings over {a,
b} such that the number of a’s is divisible by two and the number of b’s is
divisible by three.
2. Construct a DFA with minimum number of states, accepting all strings over {a,
b} such that the number of a’s is not divisible by two and the number of b’s is
divisible by three.
3. Construct a DFA with minimum number of states, accepting all strings over {a,
b} such that the number of a’s is divisible by three and the number of b’s is
divisible by two.
4. Draw a DFA which accepts all strings over {a, b} such that no string has three
consecutive occurrences of the letter b.
5. Draw a DFA which accepts all strings over {a, b} such that the set of string does
not contain abab as a substring.
6. Design a DFA to recognize all strings over {a,b} such that L={awa : w ϵ {a,b}*}.
7. Design a DFA to accept all strings over {a,b} such that L={aw1aaw2a : w1 , w2 ϵ
{a,b}* .
8. Design a DFA for Σ = {a, b} that can accept all strings with no more than three
a’s.
9. Find DFA for the following languages on Σ = {a, b}:
a. L = {w : |w| mod 3 = 0
b. L = {w : na(w) mod 3 > nb(w) mod 3}
10. Consider the set of strings on {0,1}. Design a DFA to accept all strings where
every 00 is followed immediately by a 1.
11. Draw a DFA for all binary strings divisible by 3.
12. Draw a DFA for all binary strings divisible by 2.
13. Suppose Σ = {0, 1, 2}. Draw a DFA for the language L = {w | the sum of digits in
w is divisible by 5}.
14. Draw a DFA for L = {0n1m | m ≥ 1 , n ≥ 0 ; (n + m) is divisible by 3}.
15. Suppose Σ = {a, b}. Find a DFA for the set of strings w such that the number of
occurrences of the substring ab in w equals the number of occurrences of the
substring ba in w.
16. Construct a DFA accepting all strings w over Σ = {0, 1} such that the number of
1’s in w is 3 mod 4.
17. Construct a DFA to accept all strings over Σ = {a, b} that ends in bb.
18. Design a DFA to accept all strings over Σ = {a, b} with even number of a’s and
even number of b’s.
19. Construct a DFA equivalent to the NFA defined by the regular expression
(0+1)∗00
Session: July – Nov 2025 V Semester
20. Design a DFA from the given NFA that accepts all strings over {a, b} that
contain substring “aba”.
21. Construct a DFA equivalent to the NFA accepting strings over {0,1} that end
with either 01 or 10.
22. Represent the following sets by regular expression:
a. {12n+1 | n>0
b. {The set of all strings over {0,1} which has at most two zeros.
c. {an | n is divisible by 2 or 3 or n=5}.
d. The set of all strings over {a, b} beginning and ending with a.
23. Construct a transition system corresponding to the following regular expressions:
a. (ab + c*)*b b. a + bb + bab*a
c. (ab + a)*(aa + b) d. (a*b + b*a)*a
24. Find the regular expressions representing the following sets. Then Construct the
equivalent NFA and convert that NFA into an equivalent DFA using the subset
construction method.
a. The set of all strings over {0,1} having at most one pair of 0’s or at most one
pair of 1’s.
b. The set of all strings over {a,b} in which the number of occurrences of a is
divisible by 3.
c. The set of all strings over {a,b} in which there are at least two occurrences
of b between any two occurrences of a.
d. The set of all strings over {a,b} with three consecutive b’s.
e. The set of all strings over {0,1} beginning with 00.
f. The set of all strings over {0,1} ending with 00 and beginning with 1.
25. Prove the following:
a. Arden’s theorem
b. (0*1*)* = (0 + 1)*
c. (ab)* ≠ (a*b*)
d. (r + s)* ≠ r* + s*
e. λ + 1*(011)*(1*(011)*)* = (1 + 011)*
26. Construct R.E. using Arden’s theorem from the following FA’s:
a.
a B
→q1 q1 q2
*q2 q3 q2
q3 φ φ
b.
0 1
→* q1 q2
q1
q2 q3 q2
q3 q1 q2
c.
Session: July – Nov 2025 V Semester
0 1
→*q1 q1 q2
→*q2 q3 q2
q3 q3 q3
d.
0 1
→*q1 q2 q3
q2 q4 q1
q3 q1 q4
q4 q4 q4

Session: July – Nov 2025 V Semester


e.
0 1
→*q1 q1 q1
f.
a b
→q1 q3 q2
q2 q2 q2
*q3 q3 q3
g.
0 1
→q1 q2 q2
*q2 q1 q1
h.
0 1
→q0 q1 q1
q1 φ φ
*q2 q1 q1

27. Construct a regular expression corresponding to the automata given below –

28. Construct the regular grammar for the following language.


a. The set of all strings over {0,1} having at most one pair of 0’s or at most one
pair of 1’s.
b. The set of all strings over {a,b} in which the number of occurrences of a is
divisible by 3.
c. The set of all strings over {a,b} in which there are at least two occurrences
of b between any two occurrences of a.
d. The set of all strings over {a,b} with three consecutive b’s.
e. The set of all strings over {0,1} beginning with 00.
f. The set of all strings over {0,1} ending with 00 and beginning with 1.
g. L={w01∣w∈{0,1}*}
h. L={xaby∣x,y∈{a,b}*}
i. L={aw∣w∈{a,b}*}
j. L={00,01,10,11}
k. L={ambnck∣m,n,k≥1}

Session: July – Nov 2025 V Semester


29. Construct the context free grammar for the following language.
a. L={w∣w=wR,w∈{a,b}*}
b. L={w∣w is a well-formed sequence of ( and )}
c. L={w∈{a,b}*∣ #a(w)>#b(w)}
d. L={ambn∣m is not equals n}
e. L={ambn∣m = n2}
f. L={ambncm∣m,n≥1}
g. L={ambm+ncn∣m,n≥1}

30. Consider the following grammar-


S → ABC
A→a
B→b
C→c

Consider a string w = abc.


Design all possible LMD and RMD.

Session: July – Nov 2025 V Semester


31. Consider the grammar-
S → bB / aA
A → b / bS / aAA
B → a / aS / bBB
For the string w = bbaababa, find-
1. Leftmost derivation
2. Rightmost derivation
3. Parse Tree
32. Consider the grammar-
S → A1B
A → 0A / ∈
B → 0B / 1B / ∈
For the string w = 00101, find-
1. Leftmost derivation
2. Rightmost derivation
3. Parse Tree
33. Consider the following grammar and eliminate left recursion-
A → ABd / Aa / a
B → Be / b
34. Consider the following grammar and eliminate left recursion-
E→E+E/ExE/a
35. Consider the following grammar and eliminate left recursion-
E→E+T/T
T→TxF/F
F → id
36. Consider the following grammar and eliminate left recursion-
S → (L) / a
L→L,S/S
37. Consider the following grammar and eliminate left recursion-
S → S0S1S / 01
38. Consider the following grammar and eliminate left recursion-
S→A
A → Ad / Ae / aB / ac
B → bBc / f
39. Do left factoring in the following grammar-

Session: July – Nov 2025 V Semester


S → iEtS / iEtSeS / a
E→b
40. Do left factoring in the following grammar-
A → aAB / aBc / aAc
41. Do left factoring in the following grammar-
S → bSSaaS / bSSaSb / bSb / a
42. Do left factoring in the following grammar-
S → a / ab / abc / abcd
43. Do left factoring in the following grammar-
S → aAd / aB
A → a / ab
B → ccd / ddc
44. Check whether the given grammar is ambiguous or not-
S → SS
S→a
S→b
45. Check whether the given grammar is ambiguous or not-
S→A/B
A → aAb / ab
B → abB / ∈
46. Check whether the given grammar is ambiguous or not-
S → AB / C
A → aAb / ab
B → cBd / cd
C → aCd / aDd
D → bDc / bc
47. Check whether the given grammar is ambiguous or not-
S → AB / aaB
A → a / Aa
B→b
48. Check whether the given grammar is ambiguous or not-
S → a / abSb / aAb
A → bS / aAAb
49. Convert the following ambiguous grammar into unambiguous grammar-

Session: July – Nov 2025 V Semester


R → R + R / R . R / R* / a / b
where * is kleen closure and . is concatenation.
50. Consider the given grammar-
E→E+T/T
T→FxT/F
F → id

Evaluate the following expression in accordance with the given grammar-


2+3x5x6+2
51. Consider the given grammar-
E→E+T/E–T/T
T→TxF/T÷F/F
F→G↑F/G
G → id

Evaluate the following expression in accordance with the given grammar-


2x1+4↑2↑1x1+3
52. Removal of Useless Symbols
T → xxY | xbX | xxT
X → xX
Y → xy | y
Z → xz
53. Remove the ε production from the CFG given below by preserving its meaning.
S → ABA
A → 0A | ε
B → 1B | ε
54. Removing Unit Productions:
S → 0X | 1Y | Z
X → 0S | 00
Y→1|X
Z → 01

55. Convert the given CFG to CNF. Consider the given grammar G:

Session: July – Nov 2025 V Semester


S → a | aA | B
A → aBB | ε
B → Aa | b

56. Convert the given CFG to GNF. Consider the given grammar G:
S → XB | AA
A → a | SA
B→b
X→a
57. Design a PDA for accepting a language {anb2n | n>=1}.
58. Design a PDA for accepting a language {0n1m0n | m, n>=1}.
59. Construct a PDA that accepts the language L over {0, 1} by empty stack which
accepts all the string of 0's and 1's in which a number of 0's are twice of
number of 1's.
60. Design NPDA for Palindrome strips.
61. Convert the following grammar to a PDA that accepts the same language.
S → 0S1 | A
A → 1A0 | S | ε

62. Construct PDA for the given CFG, and test whether 010000 is acceptable by this
PDA.
S → 0BB
B → 0S | 1S | 0

63. Draw a PDA for the CFG given below:


S → aSb
S→a|b|ε

64. Construct the PDA for the following language and then convert the resulting PDA
into its equivalent CFG.
a. L={w∣w=wR,w∈{a,b}*}
b. L={w∣w is a well-formed sequence of ( and )}
c. L={w∈{a,b}*∣ #a(w)>#b(w)}
d. L={ambn∣m is not equals n}
e. L={ambn∣m = n2}
f. L={ambncm∣m,n≥1}
g. L={ambm+ncn∣m,n≥1}

Session: July – Nov 2025 V Semester


Session: July – Nov 2025 V Semester

You might also like