TOC Question Bank
TOC Question Bank
QUESTION BANK
Semester: V Section: ‘A’ & ‘B’
Subject Name & Code: Theory of Computation [BCS503]
MODULE-1
δ 0 1
→p {p,q} {p}
{r}
q ∅
*r {p,r} {q}
9) Design NFA’s to recognize the following set of strings:
i) lab, cab and dab. Assume the alphabet is{a,b,c,d,l}
ii) 1101,101 and 111.Assume the alphabet is { 0,1}
Prepared by Dr. Nandini S, ISE, SJCIT page 1
Convert each of your NFA’s from i) and ii) to DFA’s.
10) Convert the following ε-NFA to DFA
δ ε 0 1
→p {r} {q} {p,r}
q ∅ {p} ∅
*r {p,q} {r} {p}
i) Compute -Closure for each state.
ii)Convert automaton to DFA.
iii) Give the set of all strings of length 3 or less accepted by the automaton.
12) Convert the following NFA to its equivalent DFA
MODULE-2
1) Define Regular expression and write the regular expression for the following:
( i)L={a2n b2m+1 | m≥0, n≥0 } (ii)L={ an bm | m+n is even } (iii)L={ an bm | m≤3, n≥4 }
iv)L={anbm | m≥1, n≥1, nm≥3} v) String of a’s and b’s having even length of a’s followed by odd
length of b’s. vi)String of a’s and b’s whose length is either evenor multiples of 3 or both.
2) Obtain a regular expression to accept the words with two (or) more letters but beginning andending
with the same letter over the input {a,b}.
3) Obtain the regular expression to accept strings of a’s , b’s,c’s such that 4th symbol from the
right is a and ends with b.
4) Give the regular expression for the following languages
i) L={w: |w| mod 4=0 } on ∑={a,b}.
ii) L={w: w contains even number of 0’s followed by odd number of 1’s}.
iii) L={w∈ {a,b}* | w has exactly one pair of consecutive a’s}.
iv) Set of all strings not ending in substring ‘ab’ over ∑={a,b}.
5) Write the regular expression for the following
i) {w ∈ {a, b}*: every a in w is immediately preceded and followed by b}.
ii) {w ∈ {a, b}* : w does not end in ba}.
iii) {anbm | m>=1, n>=1 nm>=3 } (Feb2021)
iv) {w ∈ {0, 1}* : w has 001 as a substring}.
v) {w ∈ {a, b}* : w has both aa and bb as substrings}.
vi) {w ∈ {0, 1}* : none of the prefixes of w ends in 0}.
vii) {w ∈ {a, b}* : #a(w) =3 }.
viii) {w ∈ {a, b}* : #a(w) ≤ 3}.
ix) {w ∈ {a, b}* : w contains no more than two occurrences of the substring aa}.
6) Prove that , for every regular expression there exists a finite automaton which accepts the same
language accepted by regular expression.
7) Convert the following automaton to regular expression using state elimination method
10) Prove that if L=L(A) for some DFA A, then there is a regular expression R such that L=L(R)
11) Define distinguishable and indistinguishable states. Minimize the following DFAs using table filling
algorithm:
i) (ii)
𝜎 0 1
→A B A
B A C
C D B
*
D D A
E D F
F G E
G F G
H G D
iii)
𝜎 a b
→→ q0 q1 q2
q1 q1 q3
q2 q1 q2
q3 q1 q4
*q4 q1 q2
12) Prove that regular languages are closed under union, intersection, concatenation, complementation
,reverse and homomorphism.
13) If L1 and L2 are regular then prove that L1- L2 is also regular.
14) Consider the homomorphism from the alphabet {0,1,2} to {a,b} defined by h(0)=ab, h(1)=b,
h(2)=aa.
(i)What is h(2201)?
(ii)If L is language 1*02*, what is h(L)?
(iii) If L is language (ab+bab)*bab, what is h-1(L)?
MODULE-3
1) Define Context Free Grammar. Design CFG for the following Languages.
a) L = {an bn+3| n ≥ 3 }
b) L=(01)n |n>=1
c) Let ∑ = {a, b} obtain a grammar G generating set of all palindromes over ∑.
d) Let ∑ = {a, b} obtain a grammar G generating set of all non-palindromes over ∑.
e) L= {anbn | n>=1}
f) L = {an bm | n ≥ 0, m > n} (June/Jul 2023,18 scheme)
g) L = {anb2n : n>=0} (Jan/Feb 2021,18 scheme)
h) L={wwR | w ε{a,b}*}
i) L={0m1m2n | m>=1, n>=0}
j) L={ambnck|m+2n=k & m,n>=0}
k) L={an bn-3| n ≥ 3 (Dec 2018/Jan 2019,15 scheme)
2) What is NPDA? Design NPDA for Language L = {a n bn | n >= 1}. Draw transition diagram.
Write sequence of moves made by NPDA to accept the string aaabbb. (2022, 2018,19,23,17 )
3) Define PDA. Obtain PDA to accept the language L(M) = {wcwR | w ∈ (a + b)*}, where wR is the
reverse of w by a final state. And show the moves made by PDA for the string "aabcbaa" and
"abacbba".(Jan/Feb 2023,18 scheme) (June/Jul 2023,18 scheme) (Jul/Aug 2022)
4) Construct a PDA to accept the language L = {wwR | w ∈ {a, b}* }.Draw the graphical representation of
this PDA. Show the moves made by this PDA for the string aabbaa. (Dec 2017, Jan 2018) (June/Jul
2023,17 scheme) (Jan/Feb 2023,18 scheme)
5) Design a PDA for the language that accepts the string with n a(w) < nb(w), where w ∈ {a + b}* and
show the instantaneous description of the PDA on input abbab. (Jan/Feb 2021,18 scheme)
6) Design a PDA for the language that accepts the string with n a(w) = nb(w), where w ∈ {a + b}* and
show the instantaneous description of the PDA on input abbaba.
7) Build a PDA to accept delimiters or balanced parentheses having parentheses { , ( , ) , }
8) Obtain a CFG for PDA M with the transitions:
δ(q0, a, Z) = (q0, AZ)
δ(q0, b, A) = (q0, AA)
δ(q0, a, A) = (q1, ε) (Jan/Feb 2021,15 scheme)
9) Convert the following CFG to PDA:
S → aABB | aAA
A → aBB | a
B → bBB | A
C → a (Dec 2017, Jan 2018) (Jul/Aug 2022,17 scheme)
10) Convert the following grammar into equivalent PDA:
S -> aABC
A -> aB | a
B -> bA | b
C -> a (Dec 2018/Jan 2019,15 scheme) (June/Jul 2023,17 scheme)
11) Consider the grammar G with production Obtain the left most derivation, right most derivation and
parse tree for some string for the following CFG.
a) S -> AbB
A -> Aa | ε
B -> aB | bB | ε
For the string aaabab.
b) S -> aB | bA
A -> aS| bAA | a
B -> bS | aBB | b
For the string aaabbabbba.
c) E -> E + E
E -> E - E