Date: 10-10-2024
Question Bank
Academic Year: 2024-25 Odd Semester Scheme: 2022
Course Coordinator: Ramesh Babu N Semester: 5
Subject: Theory of Computation Subject Code: BCS503
Module 2
1. Define regular expression.
2. Obtain regular expressions for the following languages.
a. {w ∈ {a, b}* : every a in w is immediately preceded and followed by b}.
b. {w ∈ {a, b}* : w does not end in ba}.
c. {w ∈ {0-9}* : w corresponds to the decimal encoding, without leading 0’s, of an odd
natural number}.
d. {w ∈ {0, 1}* : w has 001 as a substring}.
e. {w ∈ {a, b}* : w has both aa and bb as substrings}.
f. {w ∈ {0, 1}* : none of the prefixes of w ends in 0}.
g. {w ∈ {a, b}* : #a(w) ≡3 0}.
h. {w ∈ {a, b}* : #a(w) ≤ 3}.
i. {w ∈ {a, b}* : w contains no more than two occurrences of the substring aa}.
j. {a2nb2m | m>=0, n>=0 }
k. {anbm | n>=4, m<=3 }
l. {w :|w| mod 3=0 where w ε (a,b)*}
m. strings of 0's and 1's having no two consecutive 0's.
n. strings of a's and b's starting with 'a' and ending with 'b'
3. Show that every language defined by a regular expression is also defined by a finite
automaton.
4. Construct finite automata(E) for the following regular expressions(RE).
a. RE = (a + b)* aa
b. RE = (a + b)* aa (a + b)*
c. RE = a* + b* + c*
d. RE = (aa)* (bb)*
Ramesh Babu N, Assoc. Prof.,
Dept. of CS& BS, KSSEM 1
5. Obtain Regular Expression for the following automata using state elimination method.
a)
b)
c)
d)
6. State and prove pumping theorem for regular languages.
7. Prove that the following languages are not regular.
a. L= {anbn | n >= 1 }
b. L= {anb2n | n >= 1 }
c. L= {anbn+1 | n >= 0}
d. L= {an+2bn | n>=1}
e. L = {anbm : n m}
f. L = {anbm : na(w) > nb(w)}
g. L={wwR | w ε{a,b}*}
h. L={0m1m2n | m>=1, n>=0}
i. L={0i1j | ij, i>=0, j>=0}
8. Show that the regular languages are closed under the following operations.
Union, Concatenation, Closure, Complement, Intersection, Difference, Reversal,
Homomorphism, Inverse Homomorphism.
Ramesh Babu N, Assoc. Prof.,
Dept. of CS& BS, KSSEM 2
9. Explain the terms distinguishable states and indistinguishable states.
10. Minimize the following automata.
a)
b)
11. Write short notes on applications of Regular Expressions.
Ramesh Babu N, Assoc. Prof.,
Dept. of CS& BS, KSSEM 3
Module 3
1. Define Context Free Grammar.
2. Design Context Free Grammar for following languages.
a. L= {anbn | n>=0 }
b. L= {a2nbn | n>=0 }
c. L= {anb2n | n>=0 }
d. L= {a2nbn | n>=1 }
e. L= {anb2n | n>=1 }
f. L= {anbn+1 | n>=0}
g. L= {anbn+2 | n>=0}
h. L= {an+3bn | n>=1 }
i. L= {an+2bn | n>=1}
j. L = {anbm : n m}
k. L = {anbm : na(w)>nb(w)}
l. L={wwR | w ε{a,b}*}
m. L={0m1m2n | m>=1, n>=0}
n. L={0i1j | ij, i>=0, j>=0}
o. L = {anbm : n>=0, m >n}
p. L = {anbn-3m: n>=3}
q. L={w: |w|mod 3 |w|mod 2 on {a}}
r. L={w: |w|mod 3 >= |w|mod 2 on {a}}
s. L={ambmck | n+2m=k for n>=0, m>=0}
t. No more than 3 a’s on {a,b}
u. strings of 0's and 1's having substring ‘000’
v. strings of a's and b's starting with 'a' and ending with 'b'
w. strings of a’s and b’s whose length is multiple of 3.
x. L = {anbm : na(w) > nb(w) + 1}
3. What are Parse Trees and Explain the construction procedure with an example.
4. Explain Leftmost Derivation and Rightmost Derivation with an example. What is Ambiguity
in Grammars.
5. Is the following grammar ambiguous?
6. What is Inherently Ambiguous Grammar.
7. Definition of the Pushdown Automata(PDA).
8. Define the Languages of a Pushdown Automata.
9. Design Pushdown Automata for the following languages.
a. L= {anbn | n>=0 }
b. L= {anb2n | n>=1 }
c. L= {anbn+1 | n>=0}
d. L = {anbm : n m}
Ramesh Babu N, Assoc. Prof.,
Dept. of CS& BS, KSSEM 4
e. L = {w : w ε{a,b}*, na(w) = nb(w)}
f. L = {w : w ε{a,b}*, na(w) < nb(w)}
g. L = {w : w ε{a,b}*, na(w) > nb(w)}
h. L = {w : w ε{a,b}*, na(w) != nb(w)}
i. L={wcwR | w ε{a,b}*}
j. L={wwR | w ε{a,b}*}
k. L={0m1m2n | m>=1, n>=0}
l. L = {anbm : n>=0, m >n}
m. L={w: |w|mod 3 |w|mod 2 on {a}}
n. L={w: |w|mod 3 >= |w|mod 2 on {a}}
o. strings of 0's and 1's having substring ‘000’
p. strings of a's and b's starting with 'a' and ending with 'b'
q. strings of a’s and b’s whose length is multiple of 3.
10. Convert the following CFG to PDA.
I -> a | b | I a | I b | I 0 | I 1
E -> I | E * E | E + E | ( E )
11. How to find the PDA is Deterministic or not.
12. Is the following PDA Deterministic or not.
a. L= {anbn | n>=0 }
b. L= {anb2n | n>=1 }
c. L= {anbn+1 | n>=0}
d. L = {w : w ε{a,b}*, na(w) = nb(w)}
e. L = {w : w ε{a,b}*, na(w) < nb(w)}
f. L = {w : w ε{a,b}*, na(w) > nb(w)}
g. L={wcwR | w ε{a,b}*}
h. L={wwR | w ε{a,b}*}
*****
Ramesh Babu N, Assoc. Prof.,
Dept. of CS& BS, KSSEM 5