DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING ASSIGNMENT QUESTIONS Course Name: Automata Theory & Compiler Design Course Code: CS3103 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 divisible by three and the number of b’s is divisible by two. 3. Draw a DFA which accepts all strings over {a, b} such that no string has three consecutive occurrences of the letter b. 4. Design a DFA to recognize all strings over {a,b} such that L={awa : w Ο΅ {a,b}*}. 5. Design a DFA to accept all strings over {a,b} such that L={aw 1aaw2a : w1 , w2 Ο΅ {a,b}* . 6. Design a DFA for Σ = {a, b} that can accept all strings with no more than three a’s. 7. 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} 8. Consider the set of strings on {0,1}. Design a DFA to accept all strings where every 00 is followed immediately by a 1. 9. Draw a DFA for all binary strings divisible by 3. 10. Draw a DFA for all binary strings divisible by 2. 11. Suppose Σ = {0, 1, 2}. Draw a DFA for the language L = {w | the sum of digits in w is divisible by 5}. 12. Draw a DFA for L = {0n1m | m ≥ 1 , n ≥ 0 ; (n + m) is divisible by 3}. 13. 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. 14. Construct a DFA accepting all strings w over Σ = {0, 1} such that the number of 1’s in w is 3 mod 4. 15. Construct a DFA to accept all strings over Σ = {a, b} that ends in bb. 16. Design a DFA to accept all strings over Σ = {a, b} with even number of a’s and even number of b’s. 17. 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. 18. Construct a transition system corresponding to the following regular expressions: Session: July – Dec 2023 V Semester a. (ab + c*)*b b. a + bb + bab*a c. (ab + a)*(aa + b) d. (a*b + b*a)*a 19. Find the regular expressions representing the following sets: 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. 20. 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)* 21. 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. 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 – Dec 2023 V Semester e. →*q1 0 q1 1 q1 →q1 q2 *q3 a q3 q2 q3 b q2 q2 q3 →q1 *q2 0 q2 q1 1 q2 q1 →q0 q1 *q2 0 q1 φ q1 1 q1 φ q1 f. g. h. 22. Construct a regular expression corresponding to the automata given below – 23. Write down the steps for Regular expression to finite automata using Thomson’s construction. 24. Convert FA to Right Linear Regular Grammar: (a) Consider a Finite automaton (FA) as given below – (b) Consider a FA as given below – 25. Convert right linear grammar to left linear grammar for the given regular expression. RE = a(a+b)* Session: July – Dec 2023 V Semester 26. Consider a language {bn a bm a| n>=2, m>=2}to convert right linear grammar to left linear grammar. 27. Construct a FSM that recognizes the language generated by the following regular grammar G: S → a | aA | bB | ο₯ A → aA | aS B → cS | ο₯ 28. Construct the regular grammar from FSM. 29. Let L = {(10)p 1q | p, q ∈ N, p ≥ q}. Prove that L is not regular using pumping lemma. 30. Let L = {an bn | n ∈ N, n ≥ 0}. Prove that L is not regular using pumping lemma. 31. What is Context Free Grammar, Derivation Tree ( Parse Tree) , and its types? Explain with examples. 32. Consider the following grammarS → ABC A→a B→b C→c Consider a string w = abc. Design all possible LMD and RMD. 33. Consider the following grammar- S → aS / ∈ consider a string w = aaa. Design all possible LMD and RMD. 34. Consider the following grammarS → aB / bA S → aS / bAA / a B → bS / aBB / b consider a string w = aaabbabbba Derive the string w using leftmost derivation. Session: July – Dec 2023 V Semester 35. Consider the grammarS → bB / aA A → b / bS / aAA B → a / aS / bBB For the string w = bbaababa, find1. Leftmost derivation 2. Rightmost derivation 3. Parse Tree 36. Consider the grammarS → A1B A → 0A / ∈ B → 0B / 1B / ∈ For the string w = 00101, find1. Leftmost derivation 2. Rightmost derivation 3. Parse Tree 37. Consider the following grammar and eliminate left recursionA → ABd / Aa / a B → Be / b 38. Consider the following grammar and eliminate left recursionE→E+E/ExE/a 39. Consider the following grammar and eliminate left recursionE→E+T/T T→TxF/F F → id 40. Consider the following grammar and eliminate left recursionS → (L) / a L→L,S/S 41. Consider the following grammar and eliminate left recursionS → S0S1S / 01 42. Consider the following grammar and eliminate left recursionS→A A → Ad / Ae / aB / ac B → bBc / f 43. Do left factoring in the following grammar- Session: July – Dec 2023 V Semester S → iEtS / iEtSeS / a E→b 44. Do left factoring in the following grammarA → aAB / aBc / aAc 45. Do left factoring in the following grammarS → bSSaaS / bSSaSb / bSb / a 46. Do left factoring in the following grammarS → a / ab / abc / abcd 47. Do left factoring in the following grammarS → aAd / aB A → a / ab B → ccd / ddc 48. Check whether the given grammar is ambiguous or notS → SS S→a S→b 49. Check whether the given grammar is ambiguous or notS→A/B A → aAb / ab B → abB / ∈ 50. Check whether the given grammar is ambiguous or notS → AB / C A → aAb / ab B → cBd / cd C → aCd / aDd D → bDc / bc 51. Check whether the given grammar is ambiguous or notS → AB / aaB A → a / Aa B→b 52. Check whether the given grammar is ambiguous or notS → a / abSb / aAb A → bS / aAAb 53. Convert the following ambiguous grammar into unambiguous grammar- Session: July – Dec 2023 V Semester R → R + R / R . R / R* / a / b where * is kleen closure and . is concatenation. 54. Q.38 Convert the following ambiguous grammar into unambiguous grammarbexp → bexp or bexp / bexp and bexp / not bexp / T / F where bexp represents Boolean expression, T represents True and F represents False. 55. Consider the given grammarE→E+T/T T→FxT/F F → id 56. Evaluate the following expression in accordance with the given grammar2+3x5x6+2 57. Consider the given grammarE→E+T/E–T/T T→TxF/T÷F/F F→G↑F/G G → id 58. Evaluate the following expression in accordance with the given grammar2x1+4↑2↑1x1+3 59. Removal of Useless Symbols T → xxY | xbX | xxT X → xX Y → xy | y Z → xz 60. Remove the ε production from the CFG given below by preserving its meaning. S → ABA A → 0A | ε B → 1B | ε 61. Removing Unit Productions: S → 0X | 1Y | Z X → 0S | 00 Y→1|X Z → 01 62. Convert the given CFG to CNF. Consider the given grammar G: Session: July – Dec 2023 V Semester S → a | aA | B A → aBB | ε B → Aa | b 63. Convert the given CFG to GNF. Consider the given grammar G: S → XB | AA A → a | SA B→b X→a 64. Design a PDA for accepting a language {anb2n | n>=1}. 65. Design a PDA for accepting a language {0n1m0n | m, n>=1}. 66. 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. 67. Design NPDA for Palindrome strips. 68. Convert the following grammar to a PDA that accepts the same language. S → 0S1 | A A → 1A0 | S | ε 69. Construct PDA for the given CFG, and test whether 010000 is acceptable by this PDA. S → 0BB B → 0S | 1S | 0 70. Draw a PDA for the CFG given below: S → aSb S→a|b|ε 71. Q1. Let ‘L’ be the language containing only the string S where: 0 πΌπ π¦ππ’ π€πππ πππ£ππ πππππ π‘βπ πΊπ΄ππΈ π = β1 πΌπ π¦ππ’ π€πππ πππππ π‘βπ πΊπ΄ππΈ π πππ πππ¦ 72. Let L’ be the complement of language ‘L’. Show that whether language L and L’ are decidable or not. 73. Consider PDA = π = (π0 , π1 , π, π, π, π§0 , πΏ, π0 , π§0 , π) which accepts by empty stack The transitions are given as follows: (π0 , π, π§0 ) = (π0 , ππ§0 ) δ: (π0 , π, π) = (π0 , ππ) (π0 , π, π) = (π1 , π) Session: July – Dec 2023 V Semester (π1 , π, π) = (π1 , π) (π1 , π, π) = (π1 , β) (π1 , β, π§0 ) = (π1 , β) Construct the transition diagram for the above PDA. What is the language accepted by above PDA? 74. Prove that set of all languages are uncountable. 75. What is membership algorithm? Show that there is no membership algorithm available for Recursively Enumerable languages. 76. What are countable sets? Show that set of all strings over any finite alphabet are countable. 77. If a language L and its complement L’ are both recursively enumerable then show that both languages are recursive. If language L is recursive and L’ is also recursive, show that both are recursively enumerable. 78. Show that emptiness and infiniteness problem of finite automata is decidable. 79. Prove that halting problem of Turing machine is undecidable. 80. If two sets S1 and S2 are countable sets, then show that S1 U S2 is countable and S1 X S2 is also countable. Session: July – Dec 2023 V Semester