0% found this document useful (0 votes)
3 views

TOC TEST2

The document is a test on the Theory of Computation consisting of 25 questions covering topics such as regular languages, context-free languages, finite automata, and pushdown automata. Each question has multiple-choice answers, and the document includes answer keys along with hints and explanations for selected questions. The test assesses knowledge of formal language theory and automata concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

TOC TEST2

The document is a test on the Theory of Computation consisting of 25 questions covering topics such as regular languages, context-free languages, finite automata, and pushdown automata. Each question has multiple-choice answers, and the document includes answer keys along with hints and explanations for selected questions. The test assesses knowledge of formal language theory and automata concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Theory of Computation Test 1

Number of Questions: 25 Section Marks: 30

Directions for questions 1 to 25: Select the correct alterna- (C) If L1 ⊂ L2 then L1* ⊂ L2*
tive from the given choices. (D) If L1 is finite then it is regular.
1. Which of the following is FALSE? 7. Which of the following strings are generated by the
I: Any regular language is context free language. regular expression,
II: There exists a DPDA (Deterministic Push Down R = (abe)* (a + b) ba?
Automata) for every CFL. (i) e (ii) aba
(A) I only (B) II only (iii) ababba (iv) abababa
(C) Both I and II (D) Neither I nor II (A) (i), (iii) (B) (ii), (iii)
2. Which of the following figure correctly specifies the (C) (ii), (iv) (D) (i), (iv)
relation between regular languages (R), deterministic 8. The regular expression R = (abe)* ((a + b) ⋅ f) ba is
CFL’s (DC) and CFL’s (C)? equivalent to
(A) (A) (abe)* (a + b) ba (B) (abe)* ba
(C) ba (D) f
R DC C
9. Which of the following identity is FALSE for regular
expressions?
(B) (i) R + R = R (ii) RR* = R*R
(iii) eR = Re = R
R DC C (A) (i), (ii), (iii) (B) (i) only
(C) (ii), (iii) (D) None of these
10. Which of the following language is Regular?
I: {ww|w∈ {0, 1}*}
II: {w/w = wR, w∈ {0, 1}*}
(C)
III: {wwR/w ∈{0, 1*}
R DC C IV: Set of all strings with un-equal number of 0’s and
1’s.
(A) I, III only (B) II, IV only
(D)
(C) IV only (D) None of the above
11. Consider the following NFA:
DC R C
a

d
3. Consider the regular expression, RE = ab* + ba*. Then a
the reversal of RE, given by RER is equal to:
(A) ab* + ba* (B) a*b d a
(C) b*a + a*b (D) (a*b) (b*a)
4. The statement: ‘For every regular language L, every
subset of L is regular as well’ is: a a
(A) TRUE
(B) False
(C) TRUE, only if L is CFG Which of the following gives the language accepted by
(D) False, only if L is CFG. given NFA?
(A) All strings of the form ak, k ≥ 0.
5. Which of the following strings are not accepted by the
(B) All strings of the form {am an| m ≥ 0 , n ≥ 0}
language L (((010 ∪ 10)*1)*)?
(C) All strings of the form {aman | m is a multiple of 2
(A) 1 (B) 0101
and n is multiple of 3}
(C) 10101110 (D) 01001011
(D) All strings of the form {ak | k is a multiple of 2
6. Which of the following is FALSE? or 3}
(A) (L1*)* = L1* 12. Which of the following is not context-free language?
(B) L1* = (L1L1)* (i) {ak | k is a perfect square}
3.136 | Theory of Computation Test 1

(ii) {ai bj ci d j | i, j ≥ 0} 17. Consider the following NFA:


(iii) {ai b2i ai| i ≥ 0}
a,b
(A) (i), (ii) (B) (ii), (iii)
(C) (i), (iii) (D) (i), (ii), (iii) a
13. Consider the following DFA D: a

b
a a, b
a b
a b a b b
18
b

Which of the following is TRUE? a,b


(i) D accepts all strings which contain the sub-word
The number of states in its equivalent DFA is
‘ab’ two times only.
(A) 4 (B) 5
(ii) D accepts all strings which terminate with ‘b’.
(C) 6 (D) 7
(iii) The strings baabb, abbba are not in the language.
(A) (i), (ii) only (B) (iii) only 18. Which of the following language is regular?
(C) (ii), (iii) (D) (i), (iii) (i) {x = y + z | x, y, z are binary integers and x is the
sum of y and z}
14. Consider the following FA:
(ii) {w|w is a binary representation of a number great-
a er than 3}
q0 b q1 (A) (i) only (B) (ii) only
(C) Both (i) and (ii) (D) Neither (i) nor (ii)
19. Consider the following grammar:
a a
a, b a S → PaP
P → e|PaPbP|PbPaP|Pa|aP
q2
What is the language generated by this grammar over
q3 q4
b b {a, b}?
(A) Set of all strings with more a’s than b’s
b (B) Set of all strings with more b’s than a’s
(C) Set of all strings with twice a’s than b’s
Which of the following states are equivalent? (D) Set of all strings with equal number of a’s and b’s.
(i) q0, q1 (ii) q2, q3
20. Consider a regular language L. A new language
(iii) q3, q4 (iv) q0, q4
DELchar(L) = {W|W is some string from L with exactly
(A) (i), (ii) (B) (ii), (iv)
one character deleted} is defined. Then DELchar(L) is
(C) (iii) only (D) (ii), (iii) (A) a regular language
15. Consider the following FA: (B) a CFG but not regular
1 (C) neither CFG nor regular
0 1 (D) not accepted by a PDA
0 21. Consider the following grammar:
S → a Sb | P
0
P → bP | Pa | e
1 Which of the following language represents the gram-
mar?
The number of states in the minimized FA is
(A) {an bn | n∈ N}
(A) 3 (B) 2
(B) {an bm bn | m, n ∈ N}
(C) 1 (D) None of the above
(C) {an bm ap bn | n, m, p ∈ N}
16. Which of the following represents a language in autom- (D) {an bm | n > m}
ata theory?
22. Let M1 and M2 are two DFA’s with 5-tuple format as
(i) S* (ii) e
given below:
(iii) f (iv) {f}
M1 = {Q1, S, d1, S1, F1)
(v) {e}
M2 = (Q2, S, d2, S2, F2)
(A) (i), (iii) only (B) (i), (iii), (v) only
where Q1, Q2 are set of states; S is the alphabet set;
(C) (ii), (iv) only (D) (iv), (v) only
d1, d2 are transition functions; S1, S2 are start states;
Theory of Computation Test 1 | 3.137

F1, F2 are final states. Then which of the following are (B) 1–d, 2–c, 3–c, 4–a
necessary for L(M1) = L(M2)? (C) 1–a, 2–c, 3–c, 4–d
(i) Q1 = Q2 (ii) F1 = F2 (D) 1–d, 2–c, 3–b, 4–a
(iii) S1 = S2 (iv) d1 = d2 25. Consider the following FA:
(A) (i), (ii) (B) (i), (ii), (iii)
(C) (i), (ii), (iii), (iv) (D) (iii), (iv) 1 0
23. Which of the following language is both regular and q0 0 q1
context free?
1
(i) {an (bc)n : n ≥ 0} (ii) {an an an : n ≥ 0}
(A) (i) only (B) (ii) only 1 0
(C) Both (i) and (ii) (D) Neither (i) nor (ii)
q2
24. Match the following:
List I List II What is the language accepted by above FA?
(A) {w|w∈{0, 1}* and w do not end with 1}
1 r*s + s A r*
(B) {w|w∈{0, 1}* and w contains more zeros than
2 f* B f 1’s}
3 e* C e (C) {w|w∈{0, 1}* and w do not end with 01}
4 (e + r)* D r* s (D) {w|w∈{0, 1}* and w do not have consequent 0’s
and 1’s}
(A) 1–a, 2–b, 3–c, 4–d

Answer Keys
1. B 2. B 3. C 4. B 5. C 6. B 7. C 8. D 9. D 10. D
11. D 12. D 13. B 14. D 15. A 16. B 17. B 18. B 19. A 20. A
21. C 22. C 23. B 24. B 25. C

Hints and Explanations


1. Every regular language is a CFL but not vice versa. 7. Given regular expression,
Every CFL has a PDA but that PDA need not be a R = (abe)* (a + b) ba
deterministic PDA. Choice (B) ‘e’ is not accepted.
2. Regular ⊂ DCFL ⊂ CFL Choice (B) ‘aba’ is accepted.
‘ababba’ is not accepted.
3. Given regular expression,
‘abababa’ is accepted. Choice (C)
RE = ab* + ba*
RER = (ab* + ba*)R 8. fR = Rf = f, so (a + b)f = f
= (ab*)R + (ba*)R f ⋅ ba = f, (abe)* . f = f Choice (D)
= (b*)R aR + (a*)R bR 9. All the three are valid identities of regular expressions.
= (bR)*a + (aR)*b Choice (D)
= b*a + a*b Choice (C) 10. None of the four languages is regular. Finite automata
4. Given statement is false. cannot check the equality of two substrings of a string.
Ex: L = {a, b}*; subset of L is {an bn | n ∈ N}, which is Choice (D)
not regular. Choice (B) 11. Given NFA accepts number of a’s which is a multiple of
5. Given language, 2 or 3. Choice (D)
L(((010 ∪ 10)*1)*) k
12. {a | k is a perfect square}
The regular expressions which are accepted by ‘L’ are This is not context-free. The PDA can’t check whether
of the form ((m)*1)*, where m = 010 ∪ 10. a number is perfect square or not.
Any string in L is either e or ends with ‘1’. Choice (C) {ai bj ci d j | i, j ≥ 0}
6. L1* = (L1 L1)* is false. Not context free. PDA can check the equality of a, b
Let L1 = {a} then L1* will have ‘a’ but (L1 L1)* do not and c, d or a, d and b, c but not a, c and b, d.
have ‘a’. {ai b2i ai | i ≥ 0} is also not recognized by a PDA.
Choice (B) Choice (D)
3.138 | Theory of Computation Test 1

13. Given DFA accepts all strings which contain at least Consider some derivations:
two sub-words ‘ab’. It do not accept baabb, abbba. 1. S → PaP 2. S → PaP
Choice (B) →a → PaaP
14. In given FA, non-final states are {q0, q2, q3, q4} and → aa
final state is {q1}. 3. S → PaP S → PaP
4.
A state is equivalent to another state if both are either → PaPbPaP → baa
non-final or final states. → aba
Also each transition from those states leads to either \ More a’s than b’s. Choice (A)
final state or non final state only. 20. DELChar (L) is a regular language. Choice (A)
\ q0, q1 are not equivalent. 21. Given grammar,
q0, q4, are not equivalent. S → aSb|P
q2, q3 are equivalent as both are non-final states and P → bP|Pa|e
q2, q3 with ‘a’ reaches a final state and q2, q3 with ‘b’ The strings generated by given grammar are
reaches a non-final state. S→P
Similarly, q3, q4 are also equivalent. Choice (D) →e
15. Given FA is the minimal FA. No minimization is pos- S → aSb
sible. (∵ With transition ‘1’, both the non-final states → aPb
are reaching a final and non-final state). Choice (A) → ab
16. S*, f(empty), {e} are languages. Choice (B) S → a Sb
→ aPb
17. Given NFA,
→ aPab
a,b → aab
a S → aSb
q1 q2 → aPb
a → abPb
→ abb
q0
S → aSb
→ aaSbb
b
q3 q4
→ aabbb
b In the starting and end of the string we need to have
equal number of a’s and b’s. in between there will be
a,b
any number of b’s and a’s.
\ The language accepted by given grammar is
The DFA equivalent to given NFA is given as, {an bm ap bn | n, m, p ∈ N}. Choice (C)
22. L(M1) = L(M2) if Q1 = Q2; F1 = F2; S1 = S2;
a b d1 = d2. Choice (C)
→ [q0] [q1] [q3] 23. (i) is CFL but not regular.
[q1] [q1, q2] [q1] (Checking the equality of a’s and (bc) is not done
[q3] [q3] [q3, q4] using FA)
(ii) is regular and CFL.
[q1, q2] [q1, q2] [q1] {a3n | n ≥ 0} is regular.
[q3, q4] [q3] [q3, q4] Every regular language is CFL. Choice (B)
\ Number of states in the equivalent DFA is 5. 24. r* s + s = r*s
Choice (B) f* = e* = e
(e + r)* = r* Choice (B)
18. (i) is not regular. (This will be shown using pumping
Lemma). (ii) is regular and the expression is given as 25. Given FA do not accept the strings which will terminate
0*1 (0 + 1) (0 + 1) (0 + 1)* Choice (B) with ‘01’. Choice (C)
19. Given grammar is
S → PaP
P → e|PaPbP|PbPaP|Pa|aP

You might also like