TOC TEST2
TOC TEST2
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
b
a a, b
a b
a b a b b
18
b
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
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