You are on page 1of 25

133

THEORY OF COMPUTATION

This Chapter ”Theory of Computation” is taken from our Book:

ISBN : 9789386629043
134

THEORY OF
COMPUTATION 5
Regular Expression and (c) Both I and II are true
(d) Both I and II are false
Finite Automata
6.
1. Consider the language L given by the regular expression
b a
(a + b) *b (a + b) over the alphabet {a.b}. The smallest
number of states needed in a deterministic finite-state
a
automata (DFA) accepting L is ________. M:
[2017, Set 1, 1 Mark]
2. Let d denote the transition function and d denote the
extended transition function of the Î-NFA whose b
transition table is given below: [2017, Set 2, 2 Marks]
a b
δ Î a b
b
® q 0 {q 2 } {q1} {q0 } N:
q1 {q 2 } {q 2 } {q3}
q2 {q 0 } f f a
q3 f f {q2 } Consider the DFAs M and N given above. The number of
Then d (q2, aba) is states in a minimal DFA that accepts the languages
(a) f (b) {q0, q1, q3} L(M) Ç L(N) is ________. [2015, Set 1, 2 Marks]
(c) {q0, q1, q2} (d) {q0, q2, q3,} 7. The number of states in the minimal deterministic finite
3. Which one of the following regular expressions represents automata corresponding to the regular expression (0 + 1)
the language: the set of all binary strings having two * (10) is _______. [2015, Set 2, 2 Marks]
consecutive 0s and two consecutive 1s? 8. Consider the alphabet S = {0, 1}, the null/empty string l
[2016, Set 1, 1 Mark] and the sets of strings X0, X1 , and X 2 generated by the
corresponding non-terminals of a regular grammar X0, X1,
(a) (0+1)*0011(0+1)*+(0+1)*1100(0+1)*
and X2 are related as follows.
(b) (0+1)*(00(0+1)*11+11(0+1)*00)(0+1)*
X0 = 1 X1
(c) (0+1)*00(0+1)*+(0+1)*11(0+1)* X1 = 0 X1 + 1 X2
(d) 00(0+1)*11+11(0+1)*00 X2 = 0 X1 + {l}
4. The number of states in the minimum sized DFA that Which one of the following choices precisely represents the
accepts the language defined by the regular expression strings in X0? [2015, Set 2, 2 Marks]
(0 + 1) * (0 + 1) (0 + 1)* is ________.
(a) 10(0*+(10)*)1
[2016, Set 2, 1 Mark]
(b) 10(0*+(10*)*1
5. Consider the following two statements:
(c) 1(0+10)*1
I. If all states of an NFA are accepting states then the (d) 10(0+10)*1+110(0+10)*1
language accepted by the NFA is S*. 9. Let L be the language represented by the regular expression
II. There exists a regular language A such that for all
languages B, AÇB is regular. å *0011å* where å = {0,1} .
Which one of the following is CORRECT? What is the minimum number of states in a DFA that
[2016, Set 2, 2 Marks] recognizes L (complement of L)? [2015, Set 3, 1 Mark]
(a) Only I is true (a) 4 (b) 5
(c) 6 (d) 8
(b) Only II is true
135
10. Consider the finite automata in the following figure. Which of the following finite state machines is a valid minimal
DFA which accepts the same language as D?
0,1 1 (a)
b b a, b
p q r
q0 1 q1 0,1 q2 0,1 q3

a a
Which is the set of reachable states for the input string
0011? [2014, Set-1, 1 Mark]
(a) {q0, q1, q2} (b) {q0, q1} a, b
(c) {q0, q1, q2, q3} (d) {q3}
11. Which of the regular expressions given below represent a, b
the following DFA? [2014, Set-1, 2 Marks] s
(b)
0 0 1 a, b
p q b
a
r a, b
1
I 0*1(1+00*1)*
II 0*1*1+11*0*1 a, b
(c) a, b
III (0+1)*1
(a) I and II only (b) I and III only a, b b
p q r
(c) II and III only (d) I, II, and III
12. Let L1 = {w Î {0, 1}*| w has at least as many occurrences of (d)
(110)’s as (011)’s}. Let L2 = {w Î{0, 1}* | w has at least as b
p q
many occurrences of (000)’s as (111)’s}. Which one of the
following is TRUE? [2014, Set-2, 2 Marks]
(a) L1 is regular but not L2 a a
(b) L2 is regular but not L1
(c) Both L1and L2 are regular s a, b
(d) Neither L1 nor L2 are regular
16. Definition of a language L with alphabet {a} is given as
S*
13. Let S be a finite non-empty alphabet and let 2 be the following and n is a positive integer constant. What is the
power set of S*. Which one of the following is TRUE? minimum number of states needed in a DFA to recognize L ?
[2014, Set-3, 1 Mark] [2011, 2 Marks]
(a) k + 1 (b) n + 1
S*
(a) Both 2 and S* are countable (c) 2n + 1 (d) 2k + 1
17. Let W be any string of length n in {0, 1}*. Let L be the set of
(b) 2S * is countable and S* is uncountable all sub-strings of W. What is the minimum number of states
2S * is uncountable and S* is countable
in a non-deterministic finite automata that accept L?
(c)
[2010, 2 Marks]
S* (a) n – 1 (b) n
(d) Both 2 and S* are uncountable
(c) n + 1 (d) 2n – 1
14. The length of the shortest string NOT in the language (over 18. Let L = {W Î (0, 1) * | W has even number of 1s}, i.e., L is the
S= {a, b}) of the following regular expression is set of all bit strings with even number of 1’s. Which one of
______________. [2014, Set-3, 1 Mark] the regular expressions below represents L?
a*b* (ba)*a* [2010, 2 Marks]
15. A deterministic finite automata (DFA)D with alphabet (a) (0* 10* 1)* (b) 0 * (10* 10*)*
å = {a, b} is given below. [2011, 2 Marks]
(c) 0 * (10 *1)* 0* (d) 0 * 1(10 * 1) * 10 *
19. S ® aSa |bSb| a | b; The language generated by the above
b b a, b grammar over the alphabet {a, b} is the set of
p q r
[2009, 1 Mark]
(a) all palindromes
a a (b) all odd length palindromes
(c) strings that begin and with the same symbol
a, b a, b (d) all even length palindromes
s t
136
20. 1 25. Given below are two finite state automata (® indicates the
0 start state and F indicates a final state) [2008, 2 Marks]
0 0 a b
a b

®1 1 2 ®1 2 2
1 Y: Z:
The above DFA accepts the set of all strings over {0, 1} that 2 (F) 2 1 2 (F) 1 1
(a) begin either with 0 or 1 [2009, 2 Marks]
Which of the following represents the product automata
(b) end with 0
Z × Y?
(c) end with 00
(d) contain the substring 00 (a) (b)
a b a b
21. Given the following state table of an FSM with two states A
and B, one input and one output ®P Q R ®P S Q

Present Present Input Next Next Output Q R S Q R S


State A State B State A State B
0 0 0 0 0 1 R(F) Q P R(F) Q P
0 1 0 1 0 0
S Q P S P Q
1 0 0 0 1 0
1 1 0 1 0 0
0 0 1 0 1 0 (c) (d)
0 1 1 0 0 1 a b a b
1 0 1 0 1 1
1 1 1 0 0 1 ®P Q S ®P S Q
If the initial state is A = 0, B = 0, what is the minimum length Q R S Q S R
of an input string, which will take the machine to the state
A = 0, B = 1 with output = 1? [2009, 2 Marks] R(F) Q P R(F) Q P
(a) 3 (b) 4
(c) 5 (d) 6 S Q P S Q P
22. Which one of the following languages over th e
26. Which of the following is true? [2007, 1 Mark]
alphabet {0 1} is described by the regular expression (0 + 1)
(a) Every subset of a regular set is regular
* 0(0 + 1) * ? [2009, 1 Mark]
(b) Every finite subset of a non-regular set is regular
(a) The set of all strings containing the substring 00
(c) The union of two non-regular sets is regular
(b) The set of all strings containing at most two 0’s
(d) Infinite union of finite sets is regular
(c) The set of all strings containing at least two 0’s
(d) The set of all strings that begin and end with 27. A minimum state deterministic finite automata accepting
either 0 or 1. the language L = {W | W Î {0, 1}*, number of 0’s and 1’s in
23. Which of the following are regular sets? [2008, 2 Marks]
W are divisible by 3 and 5, respectively as. [2007, 2 Marks]
1. {a b | n ³ 0, m ³ 0}
n 2m
(a) 15 states (b) 11 states
(c) 10 states (d) 9 states
2. {a n bm | n = 2m} Common Data for Questions 28 and 29 :
Consider the following Finite State Automata:
3. {a n bm | n ¹ m} q3

4. {xcy | x, y,Î {a, b} *}


a b
(a) 1 and 4 (b) 1 and 3
(c) 1 only (d) 4 only b b
a b
24. Which of the following statements is false? [2008, 2 Marks]
(a) Every NFA can be converted to an equivalent DFA q0 q1 q2
a
(b) Every non-deterministic turing machine can be a
converted to an equivalent deterministic turing
machine 28. The language accepted by this automata is given by the
(c) Every regular language is also a context-free language regular expression [2007, 2 Marks]
(d) Every subset of a recursively enumerable set is (a) b * ab * ab * ab (b) (a + b)*
recursive (c) b* a (a + b)* (d) b * ab * ab *
137
29. The minimum state automata equivalent to the above FSA
has the following number of states [2007, 2 Marks] 0/01
(a) 1 (b) 2 0/00 A B C 1/10
(c) 3 (d) 4 0/01 1/10
30. The following finite state machine accepts all those
binary strings in which the number of 1’s and 0’s are (a) outputs the sum of the present and the previous bits
respectively. [2004, 2 Marks] of the input
(b) outputs 01 whenever the input sequence contains 11
1 (c) outputs 00 whenever the input sequence contains 10
1 1 (d) None of the above
35. The smallest finite automata which accepts the language
0 0 0 0 0
0 1 {x| length of x is divisible by 3} has [2002, 2 Marks]
(a) 2 states (b) 3 states
1 1 (c) 4 states (d) 5 states
36. Given an arbitrary Non-deterministic Finite Automata
(a) divisible by 3 and 2 (b) odd and even (NFA) with N states, the maximum number of states in
(c) even and odd (d) divisible by 2 and 3 an equivalent minimized DFA is at least[2001, 1 Mark]
31. The regular expression 0* (10)* denotes the same set as (a) N2 (b) 2 N
[2003, 1 Mark] (c) 2N (d) N!
(a) (1* 0)*1* (b) 0 + (0 + 10)* 37. Consider a DFA over S = {a, b} accepting all strings
(c) (0 + 1)* 10 (0 + 1)* (d) None of these which have number of a’s divisible by 6 and number of
32. Consider the following deterministic finite state automata b’s divisible by 8. What is the minimum number of states
M: that the DFA will have? [2001, 2 Marks]
Let S denotes the set of seven bit binary strings in which (a) 8 (b) 14
the first, the fourth and the last bits are 1. The number (c) 15 (d) 48
of strings in S that are accepted by M is 38. Let S and T be languages over S = {a, b} represented by
[2003, 2 Marks] the regular expressions (a + b*)* and (a + b)*, respectively.
Which of the following is true? [2000, 1 Mark]
1 0 0, 1
0 0 (a) S Ì T (b) T Ì S
1 (c) S = T (d) S Ç T = f

Context Free Grammars and


(a) 1 (b) 5
Pushdown Automata
(c) 7 (d) 8
33. Consider the NFA, M, shown below: 39. Consider the following context-free grammar over the
alphabet å = {a, b, c} with S as the start symbol:
[2017, Set 1, 1 Mark]
S ® abScT | abcT
T ® bT | b
Which one of the following represents the language
generated by the above grammar?
(a) {(ab)n(cb)n ] n ³ 1}
Let the language accepted by M be L. Let L1 be the (b) {(ab)n cb m1 cb m2 ... cb mn | n, m1 m2 ..., mn ³ 1}
language accepted by the NFA M1 obtained by changing (c) {(ab)n (cbm)n | m, n ³1}
the accepting state of M to a non-accepting state and by (d) {(ab)n(cbn)m | m,n ³ 1}
changing the non-accepting state of M to accepting 40. Consider the following grammar: [2017, Set 1, 1 Mark]
states. Which of the following statements is true?
[2003, 2 Marks] P ® xQRS
(a) L1 = {0, 1}* – L (b) L1 = {0, 1}* Q ® yz | z
(c) L1 Í 1 (d) L1 = L
R ® w|ε
34. The finite state machine described by the following state
S®y
x
diagram with A as starting state, where an arc label is What is FOLLOW(Q)?
y
(a) {R} (b) {w}
and x stands for 1-bit input and y stands for 2 bit output
(c) {w, y} (d) {w, $}
[2002, 2 Marks]
138
41. If G is a grammar with productions [2017, Set 1, 2 Marks] Which one of the following pairs of languages is generated
S ® SaS | aSb | bSa | SS | Î by G1 and G2, respectively?
where S is the start variable, then which one of the following
strings is not generated by G? (a) {ambn|m > 0 or n > 0} and {ambn|m > 0 and n > 0}
(a) abab (b) aaab (b) {ambn|m > 0 and n > 0} and {ambn|m > 0 or n ³ 0}
(c) abbaa (d) babba (c) {ambn|m ³ 0 or n > 0} and {ambn|m > 0 and n > 0}
42. Consider the context-free grammars over the alphabet {a, b, c} (d) {ambn|m ³ 0 and n > 0} and {ambn|m > 0 or n > 0}
given below. S and T are non-terminals.
47. Consider the transition diagram of a PDA given below with
[2017, Set 1, 2 Marks]
G1: S ® aSb/T, T ® CT|Î input alphabet å = {a, b} and stack alphabet G = {X,
G2 : S ® bSa\T, T ® cT|Î Z}. Z is the initial stack symbol. Let L denote the language
The language L(G1) Ç L(G2) is accepted by the PDA. [2016, Set 1, 2 Mark]
(a) Finite.
(b) Not finite but regular. a, X/XX
a, X/XZ b, X/e
(c) Context-Free but not regular.
(d) Recursive but not context-free.
43. Consider the following grammar: [2017, Set 1, 2 Marks] b, X/e e, Z/Z
stmt - > if expr then expr else expr; stmt | o
expr - > term relop term | term
term - > id | number
Which one of the following is TRUE?
id - > a| b|c
number - > [0-9] (a) L = {anbn|n ³ 0} and is not accepted by any finite
where relop is a relational operator (e.g., < , > , ...), o refers to automata
the empty statement, and if, then, else are terminals. (b) L = {an|n ³ 0} È {anbn|n ³ 0} and is not accepted by
Consider a program P following the above grammar any deterministic PDA
containing ten if terminals. The number of control flow paths (c) L is not accepted by any Turing machine that halts on
in P is ________. For example, the program every input
if e1 then e2 else e3 (d) L = {an|n ³ 0} È {anbn|n ³ 0} and is deterministic
has 2 control flow paths, e1 ® e2 and e1 ® e3. context-free
44. Consider the following expression grammar G : 48. Language L1 is defined by the grammar: S1 ® aS1b|e
[2017, Set 2, 2 Marks] Language L2 is defined by the grammar: S2 ® abS2|e
E®E–T|T Consider the following statements:
T®T+F|F
P: L1 is regular
F ® (E) | id
Which of the following grammars is not left recursive, but Q: L2 is regular
is equivalent to G? Which one of the following is TRUE?
(a) E ® E – T | T (b) E ® TE’ [2016, Set 2, 1 Mark]
T®T+F|F E’ ® –TE’ | Î (a) Both P and Q are true
F ® (E) | id T®T+F|F (b) P is true and Q is false
F ® (E) | id (c) P is false and Q is true
(c) E ® TX (d) E ® TX | (TX) (d) Both P and Q are false
X ® –TX | Î X ® –TX | +TX | Î 49. Which one of the following grammars is free from left
T ® FY T ® –id recursion? [2016, Set 2, 2 Marks]
Y ® +FY | Î (a) S ® AB
E ® (E) | id A ® Aa | b
45. Which of the following decision problems are undecidable? B ® c
[2016, Set 1, 1 Mark]
(b) S ® Ab | Bb | c
I. Given NFAs N1 and N2, is L(N1) Ç L(N2) = F?
A ® Bd | e
II. Given a CFG G = (N, S, P, S) and a string x Î S*, does
x Î L(G)? B ® e
III. Given CFGs G1 and G2 is L(G1) = L(G2)? (c) S ® Aa | B
IV. Given a TM M, is L(M) = F? A ® Bb | Sc | e
(a) I and IV only (b) II and III only
(c) III and IV only (d) II and IV only B ® d
46. Consider the following context-free grammars: (d) S ® Aa | Bb | c
[2016, Set 1, 2 Mark] A ® Bd | e
G1: S ® aS | B, B ® b | bB B ® Ae | e
G2: S ® aA | bB, A ® aA | B | e, B ® bB | e
139
50. A student wrote two context-free grammars G1 and G2 for (a) 3 only (b) 3 and 4 only
generating a single C-like array declaration. The dimension (c) 1, 2 and 3 only (d) 2 and 3 only
of the array is at least one. For example, 54. Which of the following pairs have different expressive
int a [10] [3]; power? [2011, 1 Mark]
The grammars use D as the start symbol, and use six (a) Deterministic Finite Automata (DFA) and Non-
terminal symbols int ; id [ ]num. deterministic Finite Automata (NFA)
Grammar G1 Grammar G2 (b) Deterministic Push Down Automata (DPDA) and Non-
D ® int L; D ® int L; deterministic Push Down Automata (NPDA)
L ® id [E L ® id E (c) Deterministic single-tape turing machine and non-
E ® num] E ® E[num] deterministic single tape turing machine
E ® num] [E E ® [num] (d) Single-tape turing machine and multi-tape turing
Which of the grammars correctly generate the declaration machine
mentioned above? [2016, Set 2, 2 Marks] 55. Which one of the following is false? [2009, 1 Mark]
(a) Both G1 and G2 (b) Only G1 (a) There is unique minimal DFA for every regular
(c) Only G2 (d) Neither G1 nor G2 language
51. Consider the NPDA < Q = {q0, q1, q2}, S = {0, 1}, (b) Every NFA can be converted to an equivalent PDA
G = {0, 1,}^d, q0, ^, F = {q2}>, where (as per usual (c) Complement of every context-free language is recursive
convention) Q is the set of states, S is the input alphabetd (d) Every non-deterministic PDA can be converted to an
is the stack alphabet, d is the state transition function, q0 is equivalent deterministic PDA
the initial state, ^ is the initial stack symbol, and F is the set 56. Which of the following statements are true? [2008, 2 Marks]
of accepting states. The state transition is as follows: 1. Every left-recursive grammar can be converted to a
right-recursive grammar and vice-versa.
2. All e-productions can be removed from any context-
1, Z ® Z 0, 1Z ® Z free grammar by suitable transformations.
0, Z ® 0Z 1, 0Z ® Z 3. The language generated by a context-free grammar all
q0 q1 q2 of whose productions are of the form X ® W or X ®
WY (where, W is a string of terminals and Y is non-
terminal), is always regular.
4. The derivation trees of strings generated by a context-
0/1/ Î
, Z Z® Î, ^ ® Î free grammar in Chomsky Normal Form are always
binary trees.
(a) 1, 2, 3 and 4 (b) 2, 3 and 4
Which one of the following sequences must follow the (c) 1, 3 and 4 (d) 1, 2 and 4
57. Which of the following problems is undecidable?
string 101100 so that the overall string is accepted by the
(a) Membership problem for CFGs [2007, 1 Mark]
automata? [2015, Set 1, 2 Marks] (b) Ambiguity problem for CFGs
(a) 10110 (b) 10010 (c) Finiteness problem for FSAs
(c) 01010 (d) 01001 (d) Equivalent problem for FSAs
52. In the context of Abstract-Systax-Tree (AST) and Control- 58. Consider the following statements about the context-free
Flow-Graph (CFG), which one of the following is TRUE? grammar: [2006, 2 Marks]
[2015, Set 2, 1 Mark] G = {S ® SS, S ® ab, S ® ba, S ® Î}
(a) In both AST and CFG, let node N2 be the successor of 1. G is ambiguous.
node N1. In the input program, the code corresponding 2. G produces all strings with equal number of a’s and b’s.
to N2 is present after the code corresponding to N1 3. G can be accepted by a deterministic PDA.
(b) For any input program, neither AST nor CFG will Which combination below expresses all the true statements
about G?
contain a cycle
(a) 1 only (b) 1 and 3
(c) The maximum number of successors of a node in an
(c) 2 and 3 (d) 1, 2 and 3
AST and a CFG depends on the input program 59. Let Nf and Np denote the classes of languages accepted by
(d) Each node in AST and CFG corresponds to at most one non-deterministic finite automata and non-deterministic push-
statement in the input program. down automata, respectively. Let Df and Dp denote the
53. Which of the following is/are undecidable? classes of languages accepted by deterministic finite
1. G is a CFG. Is L(G) = F? automata and deterministic push-down automata
2. G is a CFG. Is L(G) = å*? respectively. Which one of the following is true?
3. M is a Turing machine. Is L(M) regular? [2005, 2 Marks]
4. A is a DFA and N is an NFA. Is L(A) = L(N)? (a) Df Ì Nf and Dp Ì Np (b) Df Ì Nf and Dp = Np
[2013, 2 Marks] (c) Df = Nf and Dp = Np (d) Df = Nf and Dp Ì Np
140
60. Consider the following grammar G: (a) {ambn | m ³ n, n > 0 }
S ® bS|aA|b (b) {ambn | m ³ n, n ³ 0 }
A ® bA |aB (c) {ambn | m > n, n ³ 0 }
B ® bB|aS| a (d) {ambn | m > n, n > 0 }
Let Na (W) and Nb (W) denote the number of a’s and b’s 66. The minimum possible number of states of a deterministic
in a string W respectively. finite automata that accepts the regular language L =
The language L(G) Í {a, b}+ generated by G is {w1aw2|w1,w2 Î{a, b}*, | w1| = 2, |w2| ³ 3} is ________.
(a) {W|Na(W) > 3Nb(W)} [2004, 2 Marks] [2017, Set 2, 1 Mark]
(b) {W|Nb(W) > 3Na(W)} 67. Consider the following languages.
[2017, Set 2, 2 Marks]
(c) {W|Na(W) = 3k, kÎ{0, 1, 2,...}}
L1 = {ap | p is a prime number}
(d) {W|Nb (W) = 3k, k Î{0, 1, 2,...}} L2 = {anbmc2m | n ³ 0, m ³ 0}
61. Let G = ({S}, {a, b}, R, S) be a context-free grammar L3 = {anbnc2n | n ³ 0}
where the rule set R is S®aSb|SS| Î L4 = {an bn | n ³ 1}
Which of the following statements is true? Which of the following are CORRECT?
[2003, 2 Marks] I. L1 is context-free but not regular.
(a) G is not ambiguous II. L2 is not context-free.
(b) There exist X, Y ÎL(G) such that XY ÎL(G) III. L3 is not context-free but recursive.
(c) There is a deterministic push-down automata that IV. L4 is deterministic context-free.
accepts L(G) (a) I, II and IV only (b) II and III only
(d) We can find a deterministic finite state automata that (c) I and IV only (d) III and IV only
accepts L(G) 68. Which of the following languages is generated by the given
62. Consider the following decision problems: grammar? [2016, Set 1, 1 Mark]
[2000, 2 Marks]
P1. Does a given finite state machine accept a given S ® aS | bS | e
string? (a) {anbm |n, m > 0}
P2. Does a given context-free grammar generate an
(b) {w Î {a, b}*|w has equal number of a’s and b’s}
infinite number of strings?
Which of the following statements is true? (c) {an|n > 0} È {bn | n > 0} È {anbn|n > 0}
(a) Both P1 and P2 are decidable (d) {a,b}*
(b) Neither P1 nor P2 are decidable 69. Let X be a recursive language and Y be a recursively
(c) Only P1 is decidable enumerable but not recursive language. Let W and Z be
(d) Only P2 is decidable two languages such that Y reduces to W, and Z reduces
to X (reduction means the standard many-one reduction).
Regular and Context Free Language
Which one of the following statements is TRUE?
63. Consider the following languages over the alphabet [2016, Set 1, 2 Mark]
å = {a, b, c}. [2017, Set 1, 2 Marks] (a) W can be recursively enumerable and Z is recursive.
Let L1 = { an bn cm | m,n ³ 0} and L2 = { am bn cn | m, n ³ 0}. (b) W can be recursive and Z is recursively enumerable.
Which of the following are context-free languages? (c) W is not recursively enumerable and Z is recursive.
I. L1 È L2
(d) W is not recursively enumerable and Z is not
I. L1 Ç L2 recursive.
(a) I only (b) II only
70. Consider the following types of languages: L1 : Regular,
(c) I and II (d) Neither I nor II
L2 : Context-free, L3 : Recursive, L4 : Recursively
64. Let L1 L2 be any two context-free languages and R be any
enumerable. Which of the following is/are TRUE?
regular language. Then which of the following is/are
CORRECT? [2017, Set 2, 1 Mark] [2016, Set 2, 1 Mark]
I. L1 È L2 is context-free. I. L3 È L4 is recursively enumerable
II. L1 is context-free.
III. L1 – R is context-free. II. L2 È L3 is recursive
IV. L1 Ç L2 is context-free.
III. L*1 Ç L2 is context-free
(a) I. II and IV only (b) I and III only
(c) II and IV only (d) I only IV. L1 È L2 is context-free
65. Identify the language generated by the following grammar,
(a) I only
where S is the start variable. [2017, Set 2, 1 Mark]
(b) I and III only
S ® XY
X ® aX | a (c) I and IV only
Y ® aYb |Î (d) I, II and III only
141
71. Consider the following languages: 77. Let L be a language and L be its complement. Which one
L1 = {anbmcn+m : m, n ³ 1} of the following is NOT a viable possibility?
L2 = {anbnc2n : n ³ 1} [2014, Set-1, 2 Marks]
Which one of the following is TRUE? (a) Neither L nor L is recursively enumerable (r.e.).
[2016, Set 2, 2 Marks]
(a) Both L1 and L2 are context-free. (b) One of L and L is r.e. but not recursive; the other is
(b) L1 is context-free while L2 is not context-free. not r.e.
(c) L2 is context-free while L1 is not context-free. (c) Both L and L are r.e. but not recursive.
(d) Neither L1 nor L2 is context-free. (d) Both L and L are recursive.
72. For any two languages L1 and L2 such that L1 is context-free 78. If L1 = {an | n ³ 0} and L2 = {bn | n ³ 0}, consider
and L2 is recursively enumerable but not recursive, which of
[2014, Set-2, 1 Mark]
the following is/are necessarily true?
(I) L1.L2 is a regular language
I. L1 (complement of L1) is recursive (II) L1.L2 = {anbn | n ³ 0}
II. Which one of the following is CORRECT?
L2 (complement of L2) is recursive
(a) Only (I) (b) Only (II)
III. L1 is context – free (c) Both (I) and (II) (d) Neither (I) nor (II)
79. Consider the following languages over the alphabet
IV. L1 È L2 is recursively enumerable
S = {0, 1, c}:
[2015, Set 1, 1 Mark] L1 = {0n1n | n ³ 0}
(a) I only (b) III only L2 = {wcwr |w Î {0, 1}*}
(c) III and IV only (d) I and IV only L3 = {wwr |w Î {0, 1}*}
73. Which of the following languages is/are regular? Here, wr is the reverse of the string w. Which of these
L1: {wxwR|w, x Î {a, b}* and |w|, |x| > 0}, languages are deterministic Context-free languages?
wR is the reverse of string w [2014, Set-3, 2 Marks]
L2: {anbm | m ¹ n and m, n ³ 0} (a) None of the languages
L3 : {apbqcr | p, q, r ³ 0} [2015, Set 2, 2 Marks] (b) Only L1
(a) L1 and L3 only (b) L2 only (c) Only L1 and L2
(c) L2 and L3 only (d) L3 only (d) All the three languages
74. Which of the following languages are context-free? 80. Consider the following languages:
L1 = {ambnanbm |m, n ³ 1}
L2 = {ambnambn|m, n ³ 1} {
L1 = 0p 1q 0r | p, q, r ³ 0 | }
L3 = {ambn|m = 2n+1}
= {0 }
[2015, Set 3, 2 Marks] p q
(a) L1 and L2 only (b) L1and L3 only L2 1 0 r p, q, r ³ 0, p ¹ r
(c) L2 and L3 only (d) L3 only Which one of the following statements is false?
75. Which one of the following is TRUE ? [2013, 2 Marks]
[2014, Set-1, 1 Mark] (a) L2 is context-free
(a) The language L = {anbn| ³ 0} is regular.. (b) L1 Ç L2 is context-free
(b) The language L = {an| n is prime} is regular. (c) Complement of L2 is recursive
(c) The language L = {w | w has 3k + 1b's for some k Î N (d) Complement of L1 is context-free but not regular
with S = {a, b}} is regular. 81. Consider the languages L1 = F and L2 = {a}. Which one
(d) The language L = {ww | wÎ S* with S = {0, 1}} is of the following represents L1 L2* È L1*? [2013, 1 Mark]
regular. (a) {e} (b) F
76. Let A £ m B denotes that language A is mapping reducible (c) a* (d) (e, a)
(also known as many-to-one reducible) to language B. 82. Let W(n) and A(n) denote respectively, the worst case and
Which one of the following is FALSE? average case running time of an algorithm executed on an
[2014, Set-2, 1 Mark] input of size n. Which of the following is always true?
[2012, 1 Mark]
(a) If A £m B and B is recursive then A is recursive. (a) A(n) = W (W(n)) (b) A(n) = Q (W(n))
(b) If A £m B and A is undecidable then B is undecidable. (c) A(n) = O (W(n)) (d) A(n) = o (W(n))
83. Consider the languages, L1, L2 and L3 as given below
(c) If A £m B and B is recursively enumerable then A is
recursively enumerable. {
L1 = 0p1q | p, q Î N } [2011, 2 Marks]
(d) If A £m B and B is not recursively enumerable then
A is not recursively enumerable. L 2 = {0 p1q | p, q Î N and p = q} and
142

{ }
3. Whether two push-down automata accept the same
L3 = 0 p1q 0 r | p, q, r Î N and p = q = r language.
4. Whether a given grammar is context-free
Which of the following statements is not true?
(a) Push Down Automata (PDA) can be used to recognize (a) 1 and 2 (b) 1 and 4
L1 and L2 (c) 2 and 3 (d) 2 and 4
(b) L1 is a regular language. 90. Which of the following is true for the language {ap | p is a
(c) All the three languages are context-free prime}? [2008, 1 Mark]
(d) Turning machines can be used to recognize all the (a) It is not accepted by a turning machine
languages (b) It is regular but not context-free
84. Let P be a regular language and Q be a context free language (c) It is context-free but not regular
such that Q Í P . For example, let P be the language (d) It is neither regular nor context-free, but accepted by a
represented by the regular expression p*q* and Q be turing machine

( Qn pn qn n Î N ) . Then which of the following is always 91. The language L = {0i21i | i ³ 0} over the alphabet {0, 1, 2} is
(a) not recursive [2007, 2 Marks]
regular? [2011, 1 Mark] (b) is recursive and is a deterministic CFL
(a) P Ç Q (b) P – Q (c) is a regular language
(c) å * - P (d) å * - Q (d) is not a deterministic CFL but a CFL
85. Let L1 be a recursive language. Let L2 and L3 be languages 92. Which of the following languages is regular?

{WW | W Î {0,1} }
that are recursively enumerable but not recursive. Which of R +
the following statements is not necessarily true? (a) [2007, 2 Marks]
[2010, 1 Mark]
(a) L2 – L1 is recursively enumerable
(b) L1 – L3 is recursively enumerable
(b) {WWR X | X, W Î{0,1}+ }
(c) L 2 Ç L1 is recursively enumerable (c) {WXWR | X, W Î {0,1}+ }
{XWW R | X, W Î {0,1}+ }
(d) L 2 È L1 is recursively enumerable
86. Consider the languages L1 = {0i1j | i ¹ j}, L2 = {0i1j | i = j}, (d)
L3 = {0i1j | i = 2j + 1 j}, L4 = {0i1j | i ¹ 2j}. Which one of the 93. Let L1 be a regular language, L2 be a deterministic context-
following statements is true? [2010, 2 Marks] free language and L3 a recursively enumerable but not
(a) Only L2 is context-free recursive language. Which one of the following statements
(b) L2 and L3 are context-free is false? [2006, 1 Mark]
(c) L1 and L2 is context-free (a) L1 Ç L2 is a deterministic CFL
(d) All are context free
(b) L2 Ç L1 is recursive
87. Let L1 = L1 Ç L 2 , where L1 and L2 are languages as defined (c) L1 Ç L2 is context-free
below
(d) L1 Ç L2 Ç L3 is recursively enumerable
{ }
L1 = a m b m c a n b n | m, n ³ 0
94. For S Î (0 + 1) * let d(s) denotes the decimal value of s (e.g.,
d(101) = 5) [2006, 1 Mark]
L 2 = {a i b jck | i, j, k ³ 0} Which one of the following statements is true?
Then L is [2009, 2 Marks] (a) L is recursively enumerable but not recursive
(a) not recursive (b) L is recursively but not context-free
(b) regular (c) L is context-free but not regular
(c) context-free but not regular (d) L is regular
(d) recursively enumerable but not context-free 95. If s is a string over (0 + 1)* then let n0(s) denotes the number
88. If L and L are recursively enumerable, then L is of 0’s in s and n1(s) the number of 1’s in s. Which one of the
[2008, 1 Mark] following languages is not regular? [2006, 2 Marks]
(a) regular (b) context-free (a) L = {s Î (0 + 1)* | n0(s) is a 3-digit prime}
(c) context-sensitive (d) recursive (b) L = {s Î (0 + 1)* | for every prefix s¢ of s,
89. Which of the following are decidable? [2008, 1 Mark] | n0(s¢) – n1(s¢) £ 2}
1. Whether the intersection of two regular languages is (c) L = {s Î (0 + 1)* | n0(s) – n 1(s)| £ 4
infinite.
(d) L = {s Î (0 + 1)* | n0(s) mod 7 = n1(s) mod 5 = 0}
2. Whether a given context-free language is regular.
143
96. Let L1 = {0n+m1n0m |n, m ³ 0}, L2 = {0n+m1n + m0m |n, m ³ 0}, and (a) Both S1 and S2 are true
L3 = {0n+m1n + m 0n + m |n, m ³ 0}. Which of these languages is/ (b) S1 is true but S2 is not necessarily true
are not context free? [2006, 1 Mark] (c) S2 is true but S1 is not necessarily true
(a) L1 only (b) L3 only (d) Neither is necessarily true
(c) L1 and L2 (d) L2 and L3 101. The language {ambncm+n|m,n ³ 1} is
97. Consider the languages: [2005, 2 Marks] (a) regular [2004, 2 Marks]
L1 = {WW | W Î {0, 1)*}
R
(b) context-free but not regular
L2 = {W # WR | W Î {0, 1)*} where # is a special symbol (c) context-senstitive but not context-free
L3 = {W W | W Î {0, 1)*} (d) type-0 but not context-sensitive
Which one of the following is true? 102. If the strings of a language L can be effectively
(a) L1 is a deterministic CFL enumerated in lexicographic (i.e., alphabetic) order, which
(b) L2 is a deterministic CFL of the following statements is true? [2003, 1 Mark]
(c) L3 is a CFL but not a deterministic CFC (a) L is necessarily finite
(b) L is regular but not necessarily finite
(d) L3 is a deterministic CFL
(c) L is context-free but not necessarily regular
98. Let L1 be a recursive language, and let L2 be a recursively
(d) L is recursive but not necessarily context-free
enumerable but not a recursive language. Which one of the
103. Consider two languages L1 and L2, each on the alphabet
following is true? [2005, 2 Marks] S. Let f : S ® S be a polynomial time computable
(a) L1 is recursive and L2 is recursively enumerable bijection such that ( "X) [X Î L1 iff f(X) ÎL2].
Further, let f–1 be also polynomial time computable.
(b) L1 is recursive and L2 is not recursively enumerable Which of the following cannot be true?
[2003, 2 Marks]
(c) L1 and L2 are recursively enumerable
(a) L1 Î P and L2 is finite
(d) L1 is recursive enumerable and L2 is recursive (b) L1 Î NP and L2 ÎP
(c) L1 is undecidable and L2 is decidable
99. Consider the machine M: [2005, 2 Marks] (d) L1 is recursively enumerable and L2 is recursive
104. Define languages L0 and L1 as follows
a L0 = {< M, W, 0 > |M halts on W}
b b L1 = {<M, W, 1>| M does not halts on W}
a b b Here < M, W, i > is a triplet, whose first component, M
is an encoding of a turing machine, second component W
is a string and third component i is a bit.
a a Let L = L0 È L1. Which of the following is true?
[2003, 2 Marks]

a, b (a) L is recursively enumerable, but L is not


(b) L is recursively enumerable, but L is not
The language recognized by M is (c) Both L and L are recursive
(a) {W Î (a, b)* | every a in W is followed by exactly two (d) Neither L nor L is recursively enumerable
b’s} 105. The language accepted by a push-down automata in which
(b) {W Î (a, b)* | every a in W is followed by at least two the stack is limited to 10 items is best described as
b’s} (a) context-free [2002, 1 Mark]
(c) {W Î (a, b)* | W contains the substring abb} (b) regular
(d) {W Î (a, b)* | W does not contain aa as a substring} (c) deterministic context-free
100. L1 is a recursively enumerable language over S. An (d) recursive
algorithm A effectively enumerates its words as W1, W2, 106. Which of the following is true? [2002, 1 Mark]
W3,... define another language L2 over S È{#} as {Wi # (a) The complement of a recursive enumerable language
Wj : W1, Wj Î L1,i < j}. Here, # is a new symbol. Consider is recursive
the following assertions. (b) The complement of a recursively enumerable
S1 –L1 is recursive implies L2 is recursive language is recursively enumerable
S2 –L2 is recursive implies L1 is recursive (c) The complement of a recursive language is either
Which of the following statements is true? recursive or recursively enumerable
[2004, 2 Marks] (d) The complement of a context-free language is
contxt-free
144
107. The C language is [2002, 1 Mark] Pumping Lemma and NP Completeness
(a) a context-free language
(b) a context-sensitive language 114. Match the List I with List II and select the correct answer
(c) a regular language using the codes given below the lists. [2008, 2 Marks]
(d) parsable fully only be a turing maching List I List II
108. Consider the languages [2002, 2 Marks] E. Checking that P. L = {anbmcndm |m ³ 1, m, ³ 1|}
identifiers are
{ } { }
L1 = a n b n cm | n, m > 0 and L2 = a n b m cm | n, m > 0 declared before their
F. Number of formal Q. X ® XbX | XcX | dxf | g
Which one of the following statements is false? parameters in the
(a) L1 Ç L2 is a context-free language declaration of a
(b) L1 È L2is a context-free language function agrees with
(c) L1 and L2 are context-free language the number of actual
(d) L1 Ç L2 is a context-sensitive language parameters in use of
109. Which of the following statements is true? that function
[2001, 1 Mark] G. Arithmetic R. L = {WcW | W Î (a | b)*}
(a) If a language is context-free it can always be expressions with
accepted by a deterministic push-down automata matched pairs of
(b) The union of two context-free languages is context- parentheses
free H. Palindromes S. X ® bXb |cXc| e
(c) The intersection of two context-free languages is (a) E - P, F - R, G - Q, H - S
context-free (b) E - R, F - P, G - S, H - Q
(d) The complement of a context-free language is (c) E - R, F - P, G - Q, H - S
context-free (d) E - P, F - R, G - S, H - Q
110. Consider the following languages: 115. Let SHAM3 be the problem of finding a Hamiltonian cycle in
a graph G = (V, E) with |V| divisible by 3 and DHAM3 be the
L1 = {WW| W Î {a, b}*}
problem of determining if a Hamiltonian cycle exists in such
L2 = {WWR| W Î {a, b}*,WR is the reverse of W} graphs. Which one of the following is true? [2006, 2 Marks]
L3 = {02i| i si an integer} (a) Both DHAM3 and SHAM3 are NP-hard
L4 = {0i2|i is an integer} (b) SHAM3 are NP-hard but DHAM3 is not
Which of the languages are regular? [2001, 2 Marks] (c) DHAM3 is NP-hard, and SHAM3 is not
(d) Neither DHAM3 nor SHAM3 is NP-hard
(a) L1 and L2 (b) L2, L3 and L4
116. Let S be an NP-complete problem and Q and R be two other
(c) L3 and L4 (d) Only L3 problems not known to be in NP. Q is polynomial time
111. Consider the following two statements: reducible to S and S is polynomial time reducible to R. Which
S1 – {02n| n ³ 1|} is regular language. one of the following statements is true? [2006, 1 Mark]
S2 – {0m1n0m+n|m ³ 1 and n ³ 1|} is a regular language (a) R is NP-complete (b) R is NP-hard
Which of the following statements is correct? (c) Q is NP-complete (d) Q is NP-hard
117. Consider the following two problems on undirected graphs:
(a) Only S1 is correct [2001, 1 Mark]
a — Given, G (V, E), does G have an independent set of size
(b) Only S2 is correct |V| – 4?
(c) Both S1 and S2 are correct b — Given, G (V, E), does G have an independent set of size 5?
(d) None of these Which one of the following is true? [2005, 2 Marks]
112. Let L denotes the language generated by the grammar (a) a is in P and b is NP-complete
S ® 0S0/00. Which of the following is true? (b) a is NP-complete b is in P
(a) L = 0+ [2000, 1 Mark] (c) Both a and b are NP-complete
(d) Both a and b are in P
(b) L is regular but not 0+
118. The problems 3-SAT and 2-SAT are [2004, 1 Mark]
(c) L is context-free but not regular (a) both in P
(d) L is not context-free (b) both NP-complete
113. What can be said about a regular language L over {a} (c) NP-complete and in P respectively
whose minimal finite state automaton has two states? (d) undecidable and NP-complete respectively
(a) L must be {an|n is odd} [2000, 2 Marks] 119. Ram and Shyam have been asked to show that a certain
n
problem P is NP-complete. Ram shows a Polynomial
(b) L must be {a |n is even} time reduction from the 3-SAT problem to II, and Shyam
(c) L must be {an| ³ 0} shows a polynomial time reduction from Õ to 3-SAT.
(d) Either L must be {an| n is odd}, or L must be {an | Which of the following can be inferred from these
n is even} reductions? [2003, 1 Mark]
145
(a) Õ is NP-hard but not NP-complete III. If L is a language in NP, L is Turing decidable
(b) Õ is in NP, but is not NP-complete Which of the above statements is/are true?
(c) Õ is NP-complete [2015, Set 2, 1 Mark]
(d) Õ is neither NP-hard, nor in NP (a) Only II (b) Only III
120. Nobody knows yet, if P = NP. Consider the language L (c) Only I and II (d) Only I and III
de as follows: 125. Let < M > be the encoding of a Turing machine as a string
ì(0 + 1)*;if P = NP over S = {0, 1}. Let L = {<M>| M is a Turing machine that
L= í accepts a string of length 2014}. Then, L is
î f; otherwise [2014, Set-2, 2 Marks]
Which of the following statements is true? (a) decidable and recursively enumerable
[2003, 1 Mark] (b) undecidable but recursively enumerable
(a) L is recursive (c) undecidable and not recursively enumerable
(b) L is recursively enumerable but not recursive (d) decidable but not recursively enumerable
(c) L is not recursively enumerable 126. Which of the following statements is/are false?
(d) Whether L is recursive or not will be known after we 1. For every non-deterministic Turing machine, there
find out if P = NP exists an equivalent deterministic Turing machine.
2. Turing recognisable languages are closed under
Turing Machines union and complementation.
121. Let A and B be finite alphabets and let # be a symbol outside 3. Turing decidable languages are closed under
both A and B. Let f be a total function from A* to B*. We intersection and complementation.
say f is computable if there exists a Turing machine M which 4. Turing recognisable languages are closed under
given an input x in A*. always halts with f(x) on its tape. Let union and intersection. [2013, 1 Mark]
Lf denote the language {x # f(x)| x Î A*}. Which of the (a) 1 and 4 only (b) 1 and 3 only
following statements is true: [2017, Set 1, 2 Marks] (c) 2 only (d) 3 only
(a) f is computable if and only if Lf is recursive. 127. Consider three decision problems P1, P2 and P3. It is known
(b) f is computable if and only if Lf is recursively that P1 is decidable and P2 is undecidable. Which one of the
enumerable. following is true? [2005, 2 Marks]
(c) If f is computable then L f is recursive, but not (a) P3 is decidable if P1 is reducible to P3
conversely. (b) P3 is undecidable if P3 is reducible to P2
(d) If f is computable then Lf is recursively enumerable, but (c) P3 is undecidable if P2 is reducible to P3
not conversely. (d) P3 is decidable if P3 is reducible to P2’s complement
122. Let L(R) be the language represented by regular expression 128. A single tape turing maching M has two states q0 and q1,
R. Let L(G ) be the language generated by a context free of which q0 is the starting state. The tape alphabet of M
grammar G. Let L(M) be the language accepted by a is {0, 1, B} and its input alphabet is {0, 1}. The symbol
Turing machine M. Which of the following decision B is the blank symbol used to indicate end of an input
problems are undecidable? [2017, Set 2, 2 Marks] string. The transition function of M is described in the
I. Given a regular expression R and a string w, is w Î following table.
L(R) ?
II. Given a context-free grammar G. is L(G) = f ? 0 1 B
III. Given a context-free grammar G. is L(G) =S*for some q0 q 1, 1, R q1, 1, R Halt
alphabet S ? q1 q 1, 1, R q 0, 1, L q0, B, L
IV. Given a Turing machine M and a string w, is w Î
L(M) ? The table is interpreted as illustrated below.
(a) I and IV only (b) II and III only The entry (q1, 1, R) in row q0 and column 1 signifies that
(c) II, III and IV only (d) III and IV only if M is in state q0 and reads 1 on the current tape square,
123. Consider the following languages: then it writes 1 on the same tape square, moves its tape
L1 = {<M> | M takes at least 2016 steps on some input}; head one position to the right and transitions to state q1
L2 = {<M> | M takes at least 2016 steps on all inputs} and Which of the following statements is true about M?
L3 = {<M> | M accepts e}; [2003, 2 Marks]
where for each Turing machine M, <M> denotes a specific (a) M does not halt on any string in (0 + 1)+
encoding of M. Which one of the following is TRUE? (b) M does not halt on any string in (00 + 1)*
[2016, Set 2, 2 Marks] (c) M halts on all strings ending in a 0
(a) L1 is recursive and L2, L3 are not recursive (d) M halts on all strings ending in a 1
(b) L2 is recursive and L1, L3 are not recursive 129. Consider the following problem X:
(c) L1, L2 are recursive and L3 is not recursive Given a turing machine M over the input alphabet S, any
(d) L1, L2, L3 are recursive state q of M and a word W Î S *, does the computation
124. Consider the following statements. of M on W visit the state q?
I. The complement of every Turing decidable language Which of the following statements about X is correct?
is Turing decidable (a) X is decidable [2001, 2 Marks]
II. There exists some language which is in NP but is not (b) X is undecidable but partially decidable
(c) X is undecidable and not even partially decidable
Turing decidable
(d) X is not a decision problem
146

Regular Expression and Finite Automata 3. (b) Option (a) contains 00 and 11 consecutively which
does not fulfill the required condition. Option (c) does
1. (4) The given regular expression is (a + b)* b (a + b). not give assurance that both 00 and 11 will be exist in
In this all string whose second last bit is ‘b’. the string.
So, the minimal NFA is According to option (d), string should start with 11
a, b and ends with 00 or vice versa. Hence option (b) is the
b a, b correct answer.
A B C 0, 1 1, 0
4. 2 +
It can be described as “All string over {a, b} ending
with ‘ba’ or ‘bb’. Then the minimal (DFA) accepting So, the minimum number of states is 2.
(L), find by converting it into minimal DFA by subset 5. (b) Statement I is not true, because if all the states of DFA
construction Algorithm. are accepting states then the language accepted by
b the DFA is å *
a
Statement II is true because one can have regular
b
A AB ABC language A = [ ] [Empty Language] which satisfies the
b given condition.
6. 1 M accepts the strings which end with a and N accepts
a b a a the strings which end with b. Their intersection should
accept empty language.
a, b
AC

Hence, it is a minimal DFA with 4 states.


2. (c) Converting the table to a state diagram then we get.
7. 3 (0 +1)*10
q1 0,1
b b 1 0
a A B C
q0 a,
q3 c

0 1
b
q2 0 1
A A AB
1
then, dˆ (q2 , aba) = All states reachable from q2 by A
B C – A B
aba. 0
If aba is broken as Î, a, Î, Î, b, a. then from q2 it can C – –
reach q1 and from there by null transaction to reach 0
state q2 as well as q0. 1
AB AC AB AC
Consider, (q2 , a) = (q2 , Î a) = {q1 , q2 q0 }. 0
(q2 , ab) = (q1 , b) = {q0 , q3 , q2 } AC A AB B C
(q2 , b) = {q0 , q2 }
K total minimum DFA states = 3
(q0 , b) = {q0 , q2 } . 8. (c)
(q2 , aba) = (q0 , a) = {q1 , q2 , q0 } 9. (b)
10. (a) Following paths can be taken by the finite Automata
(q1 , a) = {q2 , q0 } for the input string “0011”:––
(q2 , a) = {q1 , q2 , q0 } q0 uuuuuuuuu
0 rq0 uuuuuuuuu
0 rq0 uuuuuuuur
1 q0 uuuuuuuur
1 q0
(q3 , a ) = {q3 } Reachable states
Then, dˆ (q2 , aba) = {q1 , q2 , q0 } {q0 }
= {q0 , q1 , q2 } q0 uuuuuuuuu
0 rq0 uuuuuuuuu
0 rq0 uuuuuuuur
1 q0 uuuuuuuur
1 q1
Hence option (c) is correct. {q0, q1}
147

q0 uuuuuuuuu
0 rq0 uuuuuuuuu
0 rq0 uuuuuuuur
1 q1 uuuuuuuur
1 q2 19. (b) Given grammar S ® aSabSbab.
The strings generated through this grammar is
(q0, q1, q2) definitely palindromes,but not all it can only generate
We note that no other path is possible for the input palindromes of odd length only so (A) & (D) are false,
string “0011”. (B) is correct.
So, finally union of all three cases gives us the set Also it can generate palindromes which start and end
of Reachable states which is {q0, q1, q2} with same symbol, but not all strings eg. aabababba.
11. (b) (I) 0 *1(1 + 0 0 *1)* 20. (c)
(II) 0 *1*1+11*0 *1 1
(III) (0 +1)*1 1 0
(I) and (III) represent DFA.
0 0
(II) Doesn't represent as the DFA accepts strings like q0 q1 q2
11011, but the given regular expression doesn't
accept.
12. (a) L1 is regular but L2 is not 1
13. (c) S* is countabily finite
2S * is power set of S* State Input Output
The powerset of countabily infinite set is uncountable q0 to q0 1, 0 00
\ 2S* is uncountable and S* is countable. q1 to q0 1, 0 00
14. 3 a * b * (ba) * a * q2 to q0 1, 0 00
Length O is present (as it accepts Î)
Length 1 is present (a, b) Therefore, the above DFA ends with 00.
Length 2 is present (aa, ab, ba, bb) 21. (a) The initial state = 00
Length 3 is not present (bab not present) Final state required = 01
\ it is 3 Let us construct the transition diagram for the given.
15. (a) As state (s) and (t) both are final states and accepting 00 01 01
a* + b*, we can combine both states and we will get 0 0
0 1 2
b b a, b Initial state Final state
p q r We get the total number of states to be 3 when getting
the desired output. The transition diagram can further
a be elaborated as below.
a
There can be 4 states 00, 01, 10, 11.
a, b With this, the FSM can be designed as
s
0/1
1/0
16. (b) As n is constant atleast n + 1 states will required to 00 01
1/1
design ank.
17. (c) L is the set of all substrings of w where w ! {0,1})
Any string in L would have length 0 to n, with any no. 1/1 1/1 0/0
of 1’s and 0’s
The NDFA
11 0/0 10

The desired output is obtained with the input string


101, however, the concern is number of states which
we found to be 3.
22. (c) We are given with the relation
(0 + 1) * 0(0 + 1)* 0(0 + 1)*
Here, the accepting languages are
Here n = 4 L = {00, 000, 100, 001, 010, 0000, 0001, 1000, 1001, 0100,
So to accept all the substrings the no. of states 1100, 0010, 0011, 0110, 0101, 1010, ...}
required are n + 1 = 4 + 1 = 5 The common feature in the accepting languages can
Hence (c) is correct option. be seen that they consist of atleast two 0’s.
18. (b) It is given that L is the set of all bit strings with even 23. (a) Lets gather some knowledge for the regular
number of 1’s so the regular expression should exhibit expressions before going to True or False. The regular
the same. sets are defined in such a way that they have to follow
Now, the min string should be e and the string should some conventions. Conventions on regular expressions
be e, 0, 11, 101, ... 1. Bold face is not used for regular expressions when
The string obtained from such expression is 0* (10* 10 *)* the expression is not confusing. So, for example,
(r + s) is used instead (r + s).
148
2. The operation * has precedence over 26. (b) Finite subset of non-regular set is regular as we know
concatenation, which further has precedence that Pumping Lemma can be applied on all the finite
over union (+). Thus, the regular expression (a + sets that states that all finite sets are regular. Infinite
b(c*))) is written as a + bc*. union of finite set is not regular because regular sets
3. The concatenation of k r’s, where r is regular can never be closed under infinite union.
expression, is written as rk. Thus, for example rr = 27. (a) It is given that the 0’s and 1’s are divisible by 3 and 5
and we know that 3 and 5 do not have any factor other
r2. The language corresponding to rk is Lkr , where than themselves or 1 i.e., these cannot be further
Lr is language corresponding to the regular breakdown.
expression r. For a recursive definition of Lkr . Therefore, number of states = 3 × 5 = 15
The schematic representation is as follows:
4. The (r +) is used as a regular expression to
represent L+r . 1
Based on the concept, only 1 and 4 are found to 1 1 1 1
be regular since in 1, L can be written as a* (bb)* 1 2 3 4 5
and 4, (a + b) * c(a + b)* can be written for the 4.
24. (d) Option (a) True: Non-deterministic finite automata can 0 0 0 0 0 0 0
0 0
be converted into the deterministic finite automata.
Option (b) True: With reference to option (a), same is
with the non-deterministic turing machine. 0 6 1 7 1 8 1 9 1 10
Option (c) True: Regular language is always context-
free but the reverse is not true. 0 0
Option (d) False: We know that a set is a subset of 0 0 0
itself and hence, every subset of recursively
1 1 1
enumerable set is not recursive. 11 12 13 14 1 15
25. (a) Given: Transition table for Y and Z
The number of states of Z = 2 X X X X X
The number of states of Y = 2
28. (b) The FSA as obtained in the previous question is b* a
Z× Y
(a + b)*
a b a, b The minimum number of states are thus given by
b a, b
a
1 2 1 2
b a, b q1
q0
a
Y Z
q0 and q1 are the state: that are required at most and
No. of states of the product of Z and Y = 2 × 2 = 4 hence the minimum number of states is 2 (q0 and q1).
Now, the states as per the given options are P, Q, R 29. (b) The behaviour as per the given PDA is an seen below
and S. The finite state automata is q0 to q1 ® b*a
q1 to q2 ® (a + b) *
a b Regular expression = b * a (a + b)*
30. (a) The given finite state machine accepts any string W
®P S R Î(0, 1)* in which the number of 1’s is multiple of 3
and the number of 0’s is multiple of 2.
Q R S
31. (d) Option (a) solves to (1*0*)1*
R(F) Q P Option (b) solves to 0 + (0*1*0*)
Option (c) solves to 0*1*10(0*1*)
S Q P Therefore, none of the statement has the output
equivalent to the given.
Table for Z × Y is 32. (c) The strings accepted by the given automata are of
type. Option
a b 1234567
1– – 1 – – 1
® (1, 2) (2, 1) (2, 2) The four blank spaces can have a probability of
having 0 or 1, so total 2(pow,4)= 16 strings are
(1, 2) (2, 2) (2, 1) possible, but the given automata does not accept all
of those.
(2, 1) (1, 1) (1, 2) 1. 1 1 1 1 0 0 1
2. 1 1 0 1 0 0 1
F(2, 2) (1, 2) (1, 1) 3. 1 0 1 1 0 0 1
4. 1 0 0 1 0 0 1
149
5. 1 0 0 1 0 0 1 37. (d) We construct a DFA for strings divisible by 6.
6. 1 0 0 1 1 0 1 It requires minimum 6 states as length of string mod
7. 1 0 0 1 1 1 1 6 = 0, 1, 2, 3, 4, 5
Hence (c) is correct option We construct a DFA for strings divisible by 8.
33. (b) The given machine M is It requires minimum 8 states as length of string mod
8 = 0, 1, 2, 3, 4, 5, 6, 7
If first DFA is minimum and second DFA is also
minimum then after merging both DFAs resultant
DFA will also be minimum. Such DFA is called as
compound automata.
So, minimum states in the resultant DFA = 6 * 8 = 48
Thus, option (D) is the answer.
38. (c) Lets consider the regular expressions as given in the
questions:

Now, the complementary machine M is


q1

1
0
1,0
q2 q0
0, 1
Second, (a + b)*
0

In the case of DFA, L(M) = L(M) but in the case of


nfa this is not true. Infact L(M) and L (M) have no
connection.
To find L1 = L(M) , we have to look at M and
directly find its language.
Clearly, l = L(M) , since q0 is accepting it (0 + 1) Þ (a + b*)* = (a + b*)
Therefore, we can say that S = T
(0 + 1)* ÎL(M) , since q2 is accepting it.
Context Free Grammars &
\ L(M) = L1 = l + (0 + 1) (0 + 1)* Pushdown Automata
\ L1= (0 + 1)* = {0, 1}*
34. (a) As per the given diagram. 39. (c) The given context free Grammar
S = {a, b, c} with S as the start symbol.
State Input Output S ® abScT / abcT
A to A 10 00 T ® bT / b
B to A 10 00 The minimum length string generated by the grammar
C to A 10 00 is 1.
Consider first case ( S ® abcT ) then ( S ® abcb) .
Therefore, the finite state machine outputs the sum
of the present and previous bits of the input. Hence all the variable s are greater than 1.
35. (b) Answer in the book is wrong Consider second case
S ® abS cT
® ababScTcT
a b c ® ababScTcTcT
..............................
Start & end are same as (a) hence the minimum no.
of states required are3. Option (b) is correct. If string ..............................
traversal doesn't stop at (a) then string length is not ® (ab)n (CT )n
divisibleby 3. Here T can generate any number of b’s string with
36. (b) In DFA any subset of the N states (for N element set single b, so (T = bm)
N subsets possible) can become a new state and Hence, the language is
they can remain even when the DFA is minimized.
So, maximum we can get N states for the minimized L = [(ab)n (cb m )n | m, n ³ 1]
DFA. Hence option (c) is correct.
150
40. (c) Follow (Q) ? These four control flow are :
Follow (Q) is First (R) Hence First (R) = {W, E}. (1) e1 ® e2
We add ‘W’ in Follow (Q) and for Î.
We calculate : (2) e1 ® e3
First (S) = {y} (3) (e2 if e4 ) ® e5
So, follow (Q) = First (R S)
(4) (e3 if e4 ) ® e5
= {{W} – Î} È First (S)
So, for (10 “if statements”), 210 = 1024.
Follow (Q) = {W, y} (\ First (S ) = { y}) Control flow path are possible. Hence, answer is 1024.
Hence option (c) is correct.
41. (d) The given grammar with productions, 44. (c) E ® E -T |T
S ® SaS | aSb | bSa | SS | Î T ®T + F | F
Now consider,
F ® ( E ) | id
S ® aSb | bSa | SS | Î
Using the rule for removal of left recursion is
This grammar generates all strings with equal number
of ‘a’ and ‘b’. A ® Aa / b
Now, S ® SaS can only generate strings where ‘a’ is A ® bA '
more than ‘b’. Since on left and right of ‘a’ in SaS, S
will have only strings with na = nb or na > nb. A ' ® a A '/ Î
Now consider each options Then, the given grammar is written as :-
1. S ® SS ® aSbS ® abS ® abaSb ® abab, when, S ®Î
E ' ® -TE '/ Î
2. S ® aSb ® aSaSb ® aaaSb ® aaab, when S ® Î E ® +TE '
3. S ® SS ® aSbS ® abS ® abbSa ® abbSaSa T ' ® + FT '/ Î
® abbaa, when (S ® Î)
T ® FT '
4. “babba” which is a string with nb > na is not possible
to generate by the given grammar. F ® ( E ) | id
Hence, option (d) is correct. Now by putting E ' as X and T ' as Y, then
42. (b) The context free grammar given over alphabets
S = {a, b, c}, with S and T are nonterminals. X ® -TX / Î
Given, G1 : S ® aSb | T , T ® cT | Î E ® TX
G2 : S ® bSa | T , T ® cT | Î Y ® + FY / Î
Lets L(G1) is the language for Grammar (G1) and L(G2) T ® FY
is the language for Grammar (G2).
F ® ( E ) | id
where L(G1 ) = {a n cm b n | m, n ³ 0} Hence option (c) is correct.
n m n
L(G2 ) = {b c a | m, n ³ 0} 45. (c) There is no known algorithm to verify whether the
language accepted by TM is empty or not. Similarly
then L(G1 ) Ç L(G2 ) = {a n c m bn } Ç {bn c m a n } there is no algorithm to verify whether language of
CFG’s are equivalent.
= {c m | m ³ 0} = C * 46. (d) In G1, there will be atleast 1 b because S->B and B->b.
Since the only common strings will be those strings But no. of A's can be 0 as well and no. of A and B are
with only ‘C’, so the intersection is not finite but regular. independent. In G2, either we can take S->aA or S-
>bB. So it must have atleast 1 a or 1 b. So option (d) is
43. (1024) The number of control Paths is depends on number
correct.
of if statement that is 2n, where, n is the number. of if
47. (d) Initial state is also the final state.
statements
So an is also accepted.
For (2 “if statements”) 22 = 4 control flow Paths are 48. (c) L1 has the property that no. of a’s should be equal to
possible: no. of b’s in a string, and all a’s should precede all b’s.
e1 Hence extra memory will be required to check this
property of a string (Finite Automata can't be built
for this type of language). Hence this is not regular
e2 e3 language. Therefore P is False. L2 has the property
(1) (2) that no. of a’s should be equal to no. of b’s, but order
if e4 if e4
of a’s and b’s is different here, it is (ab)*, which will
require no extra memory to be accepted. (Finite
Automata can be built for this language). Hence L2
e5 e5 e5 e5
is regular language. Therefore Q is True.
151
49. (b) Grammar A has direct left recursion because of the Therefore, | Na (w) | = 3.
production rule: A®Aa. Grammar C has indirect left Also, if we use A ® bA instead of A ® aB,
recursion because of the production rules:S®Aa and S ® baA
A®Sc Grammar D has indirect left recursion because of S ® babA
production rules : A®Bd and B®Ae Grammar B doesn't To terminate A, we would have to use A ® aB as
have any left recursion (neither direct nor indirect). only B terminates at a (B ® a).
50. (a) Both G 1 and G 2 can correctly generate the S ® baA
declarations. S ® babA
51. (d) S ® babaB
52. (c) Option (a) is false when CFG contains cycle S ® babaa
Thus, here also, | Na (w) | = 3.
Option (b) is false as CFG can contain cycle
So, C is the correct answer.
Option (d) is false as a single node can contain block 61. (c) The grammar is S® aSb|SS|Î
of statements. (a) G is not ambiguous is false, since Î which
53. (d) 1. G is a CFG. Is L(G) = f? belongs to L(G), has infinite number of
Decidable derivation trees, which makes G ambiguous.
2. G is a CFG. Is L(G) = S * ? Some derivation trees are
Undecidable
3. M is a Turing Machine. Is L (M) regular?
Undecidable.
4. A is a DFA and N is an NFA. Is L(A) = L(N)?
Decidable.
Hence, the correct answer is (d) 2 and 3 only.
54. (b) DPDA and NPDA because an NPDA cannot be
converted into DPDA.
55. (d) (a) true, since minimal DFA for every regular (b) There exists x, y Î L(G) such that xy ÏL(G) is
language is possible. false, since S®SS, can be used derive xy,
(b) true, NFA can be converted into an equivalent whenever x ÎL(G) and yÎL(G).
PDA. (c) It is true, since this language is L(G) =
(c) CG’S are not recursive but their complements are. {W|na(W) = nb (W) and n a(v) ³ nb (V) where V
(d) false, since non deterministic PDA represents, is any prefix of W}
non deterministic. CFG, since NDCFG and CFG are This language happens to be deterministic
proper subsets so conversion required. context-free language.
56. (c) Statement 1 is true: Using GNF we can convert Left \ There exists a dpda that accepts it.
recursive grammar to right recursive and by using (d) It is false, as the given language is not regular.
\ number of DFA exists to accept it.
reversal of CFG and GNF we can convert right recursive 62. (a) In P1, A given finite state machine accepts a given
to left recursive. string if it is decidable because in decidable problem
Statement 2 is false: because if Î is in the language there exists a turing machine that gives the correct
then we can't remove Î production from Start symbol. answer for every statement in the domain of the
(For example L = a*) problem. A class of problems with two outputs yes
Statement 3 is true because right linear grammar or no is said to be decidable (solvable), if there exist
generates regular set some definite algorithm which always terminates
Statement 4 is true, only two non-terminals are there in (halts) with one of the two outputs yes or no.
each production in CNF. So it always form a binary tree. Similarly, in P2, the context-free grammar generates.
57. (b) Finite state automata (FSA) has no undecidability CFL
membership problem is also decidable. Regular and Context Free Language
So option (b) i.e Ambiguity of CFL cannot be decidable.
58. (b) Due to S ® S this Grammar is ambiguous right hand 63. (a) The given language over Alphabets S = (a, b, c) and
side has twoNon terminals. Also the strings like the given language are :-
aaabbb have equal no. of a’s & b’s but can’t be L1 = {a n bn c m | n, m ³ 0} is a CFL
produced by this grammar. So 2 is false.
Statement 3 is true since it is a CFG so accepted by PDA. L2 = {a m bn c n | n, m ³ 0} is also a CFL
59. (d) We know that, the languages accepted by non- then union of two CFL is always CFL,
deterministic finite automata are also accepted by
deterministic finite automata. This may not be in the L1 È L2 = {a n bm c k | (n = m) or (m = k ), n, m ³ 0} is
case of context-free languages. a context free language.
Therefore, Df = Nf and Dp Ì N p Intersection of two CFL is may or may not be a context
60. (c) Here, we have free language.
S ® bS L1 Ç L2 = {a n bm c k | (n = m) or (m = k ), n, m ³ 0} or
S ® baA (S ® aA)
S ® baaB (A ® aB) {a nb n cn | n ³ 0} is a non context free language.
S ® baaa (B ® a) Hence, option (a) is correct.
152
64. (b) 68. (d)
1. L1ÈL2 is context-free because the union of two context 69. (c)
free language is always a context free or CFL are closed 70. (d) Statement (IV) : L2 may or may not be context free
under union operation . So, it is correct. because CFL are not closed under complementation.
2. L1 is not context-free because CFL are not closed So it is not true.
under complement operation. So, it is incorrect. 71. (b) L2 is not context free. No. of b’s will match with no.
3. L1–R is context-free because if context-free language is of a’s leaving c’s to be matched with no one. So L2
intersection to the complement of regular language then cannot be context free.
it is always context-free. L1 - R = L1 Ç R1 , so it is correct. 72. (d) I Þ L1 is recursive
4. L1 Ç L2 is not context-free because context-free This one is true, because L1 is context free which is
languages are not closed under complement operations. nonentity but recursive, recursive language is closed
So it is incorrect. under complement. Hence it is true.
65. (c) The given grammar with S as start symbol is II Þ L2 (complement of L2) is recursive
S ® XY
If L2 and L2 both are recursive enumerable then L2 is
X ® ax|a Þ X ® (a m | m ³ 1) recursive
Y ® ayb|E Þ Y ® (a n bn | n ³ 0) Hence, statement II is false

S ® XY III Þ L1 is context free


S ® {a mb n | m > n, n ³ 0} Which is false because context free language does
not closed under complement.
because, from Non terminal X we can generate any
number of a's including a single 'a' and from Y equal IV Þ L1 L2 is recursive enumerable.
number of a's and b's.
Hence L = {a m bn | m > n, n ³ 0} L1 recursive, because every recursive language is
m > n, because at least one will be attached on left of also recursive enumerable.
ambn.
So, option (c) is correct.
L2 recursive enumerable.
66. (8) The Minimum possible number of states of L1 È L2 Þ recursive enumerable, because recursive
deterministic finite Automata that accepts the regular
enumerable language closed under union.
language.
73. (a) L1 = {wxwR| w, x Î {a, b}* and |w|, |x| > 0}
As given that,
wR is reverse of string w.
L = {W1 aW2 | W1,W2 Î{a, b}*, | W1 |= 2, | W2 |³ 3} is It is regular
The regular expression for L is Regular expression
= (a + b)(a + b)a(a + b)(a + b)(a + b)(a + b) * a (a + b)* a + b (a + b)* b
L2 = {anbm| m ¹ n, m, n ³ 0}
The minimal DFA accepting L is :
Hence m ¹ n, that mean n is greater than m, or m is
a, b
greater than n.
a, b a, b
So we need memory, so we can’t draw DfA for it.
a a, b a, b a, b L3 = {apbqcr|p, q, r ³ 0}
b a, b, c
a, b

Hence, the minimum number of state are 8.


67. (d) Consider the given languages.
L1 = {aP|P is a Prime Number},
L2 = {a nb m c 2m | n ³ 0, m ³ 0}
L3 = {a nbn c 2n | n ³ 0} , L4 = {a nbn | n ³ 1} .
Now, consider each option:
(i) L1 is context free but not regular is Incorrect because
it is not CFL, it is a CSL (Context sensitive language). 74. (c) L1 = ambnanbm Þ This one is CFL
(ii) L2 is not CFL is also Incorrect because it is CFL. L2 = ambnambn Þ by pumping lemma this one is not CFL.
(iii) L3 is not context free but recursive is correct because L3 = ambn |m = 2n + 1 Þ This is CFL.
L3 is CSL (context sensitive language) and every CSL 75. (c) We know that a language L is regular if an
is recursive. equivalent finite Automata can be constructed for it.
(iv) L4 is deterministic context free is correct because DFA can be constructed for L as follows:–
L4 is a proper subset of context free language. Note that L contains the strings that has 3k + 1
number of b’s (that is 4, 7, 10, .......n ...... no. of b’s
Hence option (d) is correct. and any no. of a’s)
153

a a a a a 0 0
0 1 0

q0 q1 q2 q3 q4
b b b b 1

0, 1
b
q0 is the initial state. q4 is the final state. Which is regular,
FA state remains same when input symbol is “a” at 0 1 0
any point of time.
When 1st ‘b’ is read, state is changed from q0 to q1. L1= 0 1 0
When 2nd ‘b’ is read, state is changed from q1 to q2.
When 3rd ‘b’ is read, state is changed from q2 to q3. 1
When 4th ‘b’ is read, state is changed from q3 to q4.
If no more ‘b’ is encountered, the string is accepted Regular
when last input symbol is read. Hence, the answer is (d).
However if 5th “b” is there is string, state is changed 81. (a) Considering the languages L1 = f and L2 = {a}
from q1 to q2 so that to accept the string 2 more bs For all languages L it is known that f. L = f
must be there in the string at least. Suppose, $ a string s Î f.L
Continuing in this way only those strings are
accepted that has 3k + 1 (k Î N ) number of b’s. (i.e. $ s' such that s = s' . s"
4, 7, 10 ... number of b’s). and s¢Î fs¢¢Î L
76. (d) If B is not recursively enumerable then A need not be But s¢Î f Q f is an empty language.
recursively enumerable. \ f.L=f
77. (c) Both L and L are recursively enumerable but not {e} Í L* for all languages L.
recursive. As it means taking letters from the language and
Set of recursive languages is subset of the set of concatenating them ‘0’ times creating a ‘0’ length
recursively enumerable languages. string which is possible for all languages.
So, if a language is recursive, It must be R.E. also. \ e is in f*
(a) May be true as a language L and its complement L1 . L2 = f
L need not be recursively enumerable. and L1 = {e}
(b) May be true if L is r.e. but not recursive and L L1 . L2 * È L*1 = (L1 . L2) È L*1
is not recursively enumerable \ f È {e} = {e}
(d) May be true as L and L both can be recursive. 82. (c) As we have given,
However (c) is not possible because if Both L A(n) ® Average case complexity
W(n) ® Worst case complexity
and L are recursively enumerable than by a well
As we know that average case will always be less than
known theorem of complexity theory either L
or equal to worst case complexity.
or L has to be recursive.
78. (a) A (n) £ W (n)
79. (c) L1 and L2 have deterministic push down automata Consider option (a):
but for L3 only not-deterministic PDA is possible. A(n) = W (W(n))
So L3 is not deterministic. \ It says W(n), worst case complexity is less than
80. (d) L1 = {0p1q,0r| p, q, r ³ 0} the average case complexity which is wrong because
L2 = {0p1q0r| p, q, r ³ 0, p ¹ r} W asymptotic notation shows (³) sign. Hence, this
(a) L2 is context Free – true option is false.
We can accept, or reject L2 with single stack. Consider option (b)
Insert P 0's into stack skip q 1's. A(n) = q (W(n))
\ It says A(n), worst case complexity is same as worst
For each 0 corresponding to r, remove 0 from stack.
case complexity because q notation shows equality
(b) L1 Ç L2 is context Free – true
sign. Hence, this is false.
Here L1 Ç L2 = L2 which is context Free. Consider option (c)
(c) Complement of L2 is recursive – true A(n) = O (W(n))
L2 is Context-Free language \ It says that average case complexity A(n) is less
Complement of CFL may or may not be CFL. than or equal to W(n) worst case complexity. Hence,
Complement by CFL is definately recursive. this option is correct.
(d) Complement of L1 is Context Free, but not regular Consider option (d)
false. A(n) = O (W(n))
\ It says that A(n) is strictly less than W (n), so this
L1 = {0p qq 0r } option is false.
p,q,r ³ 0
154

{ }
p q The first will produce w1, w2, ..... in L, the second
83. (c) L1 = 0 1 | p, q Î N is regular language µ1, w
µ 2 ,.... in L . Suppose now we are given any
w
L2 = {0p1q | p, q Î N and p = q} is context-free w Î S + . We first let M generate w1 and compare it
language ¶ generate
with w. If they are not the same, we let M
L3 = {0p1q 0r | p, q, r Î N and p = q= r } is not µ and compare again. If we need to continue, we next
w1
context-free. ¶ generate w
let M generate w2, then M µ 2 , and so on.
84. (c) å * - P and å * - P is the complement of P and ¶ , so
complement of regular language is also regular. Any w Î S + will be generated by either M or M
85. (b) L1 ® recursive eventually we will get a match. If the matching string is
L2,L3 ® recursively enumerable but not recursive. produced by M, w belongs to L, otherwise it is in L $.
So L1 can be recursive enumerable. The process is a membership algorithm for both L and
RE - RE = RE
So L1 - L3 is recursively enumerable. L . The process is a membership algorithm for both L
86. (d) These sort of languages are accepted by PDA, so all and L , so they are both recursive.
should be context free languages. L2 & L3 are definitely For the converse, assume that L is recursive. Then
CFL since accepted by stockof PDA. there exists a membership algorithm for it. But this
And also L1 & L4 are linear comparisons of i & j so can becomes a membership algorithm for L by simply
also be represented using PDA. So all are context free
languages. complementing its conclusion. Therefore, L is
recursive. Since any recursive language is recursively
87. (c) It is given that L = L1 Ç L 2 enumerable, the proof is completed.
Let’s first analyze the given language and check 89. (b) Statement 1 Decidable: The algorithm can be used to
whether it is context-free or not. The context-free check the finiteness/infiniteness on the DFA and also
languages are defined as below– the two given DFAs, a product DFA can be
n n
{
A context-free language is L = a b : n ³ 1 that is } constructed.
Statement 2 Undecidable: It is not decidable since the
the language of all non-empty even-length strings. It language is context-free.
consists of Statement 3 Undecidable: It is also undecidable that
1. the entire first halves of which are a’s. whether two push-down automata accept the same
2. the entire second halves of which are b’s. language.
L is generated by the grammar S ® aSb | ab, and is Statement 4 Decidable: If the LHS of each production
accepted by the push-down automata M = ({q0, q1, has one and only one variable then it is a context-free
qf}, {a, b}, {a, z), d q0, {qf}) where d is defined as grammar.
d(q0, a, z) = (q0, a) 90. (d) {aPPis a prime no.}
d(q0, a, a) = (q0, a) This prime no. is extra constraint so this language
d(q0, b, a) = (q1, x) is neither LFG nor RG but it can be accepted by
d(q1, b, a) = (q1, x) turing machine.
d(q1, l, z) = (qf, z) 91. (b) L = {0i 2li | i > 0}, this language can’t be accepted by
d (state1, read pop) = (state2, push) DFA to regular, but it is recursive & can be accepted
where z is initial stack symbol and x means pop action. by PDA to CFL.
Here, in we are given, where a and b are of equal lengths 92. (c) Lets study the regular language.
and followed by c which is of different length. This Convenstions on regular expressions
definitely shows that the languages are context-free
but not regular. 1. Bold face is not used for regular expressions
when the expression is not confusing. So, for
88. (d) LL is recursively enumerable means a TMTM accepts
all strings in LL. L¯L¯ is recursively enumerable means example, (r + s) is used instead (r + s).
a TMTM accepts all strings in L¯L¯. So, we can always 2. The operation * has precedence over
decide if a string is in LL or not, making LL recursive. concatentation, which further has precedence
over union (+). Thus, the regular expression (a
If a language L and its complement L are both + b(c*))) is written as a + bc*.
recursively enumerable, then both languages are 3. The concatenation of k r’s, where r is regular
recursive. If L is recursive, then L is also recursive, expression, is written as rk. Thus, for example rr
and consequently both are recursively enumerable.
= r2. The language corresponding to r k is Lkr ,
Proof: If L and L are both recursively enumerable,
where Lr is language corresponding to the regular
µ that serve
then there exist. Turing machines M and M
expression r. For a recursive definition of Lkr .
as enumeration procedures for L and L , respectively.
155
4. The (r +) is used as a regular expression to Now languages which are recursively enumerable but
not recursive, their complements can’t be recursively
represent L+r . enumerable.
Since, language L can be expressed as So only option (b) is correct.
r = [0 (0 + 1) * 0] + [1 (0 + 1) * 1] Hence (b) is correct option.
and follows the above convention, therefore is regular 99. (b) a is followed by two or more than 2b’s so the language
93. (b) L1 is regular language
recognized by M is {W Î {a, b} * | .
L2 is CFL.
L3 is recursively enumerable but not REC. 100. (a) S1 is TRUE.
(a) L1 I L2 is CFL is true If L1 is recursive L2 must also be recursive. Because
(b) L3 I L1 is recursive, not necessary so false. to check. If a word w = wi # wj belong to L2, we can
(c) & (d) are also true. give wiwj to the decider for L1 and if both are
94. (d) Given that, d(s) mod 5 = 2 and d(s) mod 7 ¹ 4} accepted then w belong to L1 and not otherwise.
Both the languages are regular languages, since there
S2 is TRUE.
exists deterministic finite automata for both of them.
We also have an algorithm to check the regular nature With a decider for L2 we can make a decider for L1
of the language therefore L is regular. as follows. Let w1 be the first string enumerated by
95. (c) Option (a), (b) & (d) can be accepted by DFA, & there algorithm A for L1. Now, to check if a word w
is no linear relationship between the no. of 0’s &1’s belongs to L1, make a string w¢ = w1 # w and give
in the string but in (c)n0(S) - n1(S) <=4 can’t be it to the decider for L2 and if accepted, then w
accepted by DFA, we require a PDA. Hence it is not belongs to L1 and not otherwise.
regular. So, answer must be A.
96. (d) The language is context free or not, this can be proved 101. (b) Language is not regular bcoz we need to match
by finding out the grammar for all the languages. count of c's is equal to count of b's + count of a's
{ }
L1 = 0 n + m1n 0 m | n, m ³ 0
and that can implement by PDA
¶ (q0,a,^) = (q0,a) [push a in stack, as per
The production for L1 as follows: language a comes first]
S ® 0S0 0A1 e (q
¶ 0 ,a,a) = (q 0,aa) [ push all a's into stack]
¶ (q0,b,a) = (q1,ba) [ push b in stack, state change
A ® 0A1 e to q1 that sure b comes after a]
Now, we need to apply these values of the production (q
¶ 1 ,b,b) =(q 1 ,bb) [ push all b's in stack]
individually to generate
¶ (q1,c,b) = (q2,^) [ pop one b for one c]
0 n + m n 0m ¶ (q2,c,b) = (q2,c) [ pop one b's for each c and
continue same ]
that is,
¶ (q2,c,a) = (q3,^) [ pop one a for one c , when
0m0n1n0m ® To prove
there is no more b in stack]
Applying 0S0 (m times)
S ® 0 S0, S ® 0mS0m (q
¶ 3 ,c,a) = (q3 ,^) [pop one a for each c and
Applying, S ® 0A1 continue same]
® S ® 0m 0A1 0m ¶ (q3,^,^) = (qf,^) [ if sum of c's is sum of a's and
Here applying, A ® 0 A1, n – 1 times b's then stack will be empty
S ® 0m 0 0n–1 A1n–1 10m when there is no c in input]
® S ® 0m 0n1n0m Hence, language is context- free but not regular.
Hence, proved, so L1 is context-free. 102. (d) The strings of a language L can be effectively
Going through the same procedure, we can see that enumerated means a Turing machine exists for
two comparisons are made in the L2 language, So it language L which will enumerate all valid strings of
is not context-free. the language.
L3 ® Going through the same procedure again, we If the string is in lexicographic order then TM will
can see that two comparisons are made in the L3 accept the string and halt in the final state.
language, so it is not context free. But, if the string is not lexicographic order then TM
97. (b) In all the options there is linear relationship among will reject the string and halt in non-final state.
strings so all CFL’s , but L1 & L3 can be accepted by Thus, L is recursive language.
PDA, L2 can be accepted by deterministic CFL due We cannot construct PDA for language L. So, the
to presence of special symbol D which tells the given language is not context free. Thus, option (D)
middle of the string, so deterministic. is correct.
98. (b) The rules here used will be. 103. (c) Give F and F inverse are polynomial time computable
All those languages which are recursive their functions.
complements are also recursive. Þ we can reduce L1 to L2 in polynomial time and
So option (a) & (b) can be correct. L2 to L1 in polynomial time.
156
if L1 is Un-decidable then L2 should also be Option (d) False: Similar to intersection, complement
undecidable . of a context-free language is not always a context-free
if L2 is decidable then L1 should also be decidable. language.
It is possible to convert L1 to L2 and L2 to L1 , if 110. (d) Lets study the regular language first and then will
both are decidable are , both are un-decidable. choose which language is regular.
104. (a) If L0 È L1 is recursively enumerable, it means we can Conventions on regular expression.
find out for all W ÎS*, where M halts or does not
1. Bold face is not used for regular expressions when
halt. This means that if L0 È L1 is recursively
enumerable, the halting problem would be decidable. the expression is not confusing. So, for example,
But we know, the halting problem is undecidable. (r + s) is used instead of (r + s).
Therefore L = L0 È L1 is not RE. 2. The operation * has precedence over concatenation,
c c which further has precedence over union (+). Thus,
Since, L = (L0 ÈL1)c = L 0 Ç L1 = f which is regular the regular expression (a + b(c*))) is written as a +
language and hence is RE. bc*.
Therefore, L is RE. 3. The concatenation of k r’s, where r is a regular
expression, is written as rk. Thus, for example rr = r 2.
So, correct option is (b), which is L is RE but L is not. The language corresponding to r k is Lkr , where Lr
105. (b) It is given that the stack is limited to 10 items
is the language corresponding to the regular
therefore the stack function is a type of recursion.
This directly implies that the language accepted by expression r. For a recursive definition of Lkr .
push-down automata is a regular language. 4. The (r+) is used as a regular expression to represent
106. (a) Option (a) True : The complement of recursive Lr+.
language is always recursive. L3 = {02i|i is an integer} follows all the conventions
Option (b) False : The recursively enumerable of the regular language and therefore, is regular.
language is the language, when taken its complement, 111. (a) Lets consider both the statements separately to find
lose its recursively enumerable nature. the correct option.
Option (c) False : The complement of recursive S1 : {02n |n ³ 1|}
language is always recursive and never recursively Applying the values of n,
enumerable.
® S1 = 00, 0000, 000000, ............
Option (d) False : The complement of context free
language is never context-free. The behaviour shown by the output is regular and
107. (b) C language is CSL hence, the language is a regular language.
· In C the grammar is context free.But the S2 : {0m1n0m + n| m ³ 1 and n ³ 1|}
language is context sensitive e.g. I can't declare Applying the values of m and n,
a variable twice. S2 = 0100, 00110000, 000111000000, .........
· Most of the programming languages like C, C+ Here the values of m and n are kept same so thay
+, Java etc. can be well approximate by CFG, are showing the output in symmetry but if we use
and the compilers are made taking into account the different values of m and n then the output will
CFGs. However, C language itself contains display a behaviour which is not regular. Therefore,
context sensitive properties which cannot be
confirmed is that S1 is a regular language.
deal with CFG.
112. (b) S®0S0/00
108. (a) L1 and L2 are context-free languages and therefore
S®0S0 (type 2 production)
L1 Ç L 2 may or may not be context-free, since CFLs This is a context-free grammar as in CFG, the left
are not closed under intersection. Now, let us look at hand side of the production rule has no left and
L1 Ç L 2 . right context.
L1 Ç L 2 = {anbncn | n > 0} S®00
which is clearly not context-free but is context means S®^ (null)* (type 3 production)
sensitive. This is called the regular grammar.
109. (b) Option (a) False: If the language is context-free then 113. (d) Lets take an example to solve this.
it cannot be said that the language will be accepted L1 = {n, nnn, nnnnn, ....}
by the deterministic push-down automaton as there = {n ood}
are some cases defined where the context-free = {n 2n+1; for n = 0, 1, 2, 3, 4, 5, 6,...}
language is not accepted. and L2 = {n, nnnn, nnnnnn, ...}
Option (b) True: The union of context-free languages
always produces a context-free language but it not = {n even}
the case with intersection of two context-free = {n 2n; for n = 0, 1, 2, 3, 4, 5, 6 ...}
languages. Therefore, either L must be {a n|n is odd}, or L must
Option (c) False: As discussed in Option (b). be {an |n is even}
157

Pumping Lemma and NP Completeness 122. (d) Consider each options :


(a) statement is membership problem of regular language
114. (c) The matched sequence is as given and it is decidable for finite state machine and regular
List I List II expression.
E. Checking that identifiers R. L = {WCW | W Î (a | b)*} (b) statement is emptyness problem of CFL emptyness
are declared before their problem is decidable for CFG by checking usefulness
use. of start symbol.
F. Number of formal P. L = {anbmcndm |m ³ 1, m, ³ 1|} (c) statement is a problem of CFL, and it is undecidable
problem, we can not check whether L(G) = S* or not
parameters in the
but rather we can check complement of L(G) is f.
declaration of a function
(d) statement is a membership problem of a Turing
agrees with the number
Machine and it is undecidable problem for turning
of actual parameters in machine.
use of that function
So, options (c) and (d) are undecidable.
G. Arithmetic expressions Q. X ® XbX | XcX | dxf | g
Hence option (d) is correct.
with matched pairs of 123. (c)
parentheses 124. (d) Turing decidable Þ Recursive language
H. Palindromes S. X ® bXb |cXc| e Turing recognizable Þ Recursive enumerable
language
115. (a) There is a difference between SHAM3 and DHAM3 (I) Complement of turning decidable language is
that SHAM3 is used for finding a Hamiltonian cycle in decidable which is true.
a graph but DHAM3 is the problem of determining if a (III) True (Theorem)
graph exists in a Hamiltonian cycle. Also it is given Which violates (II). Hence correct option is (d).
that |V| is divisible by 3, hence the problem can be 125. (b) The language is recursive enumerable and it is
reduced from 3 SAT which further determines that undecidable
SHAM3 and DHAM3 are NP hard. 126. (c) 1. Non-deterministic Turing Machine can be
116. (b) (A) Incorrect because R is not in NP. A NP Complete simulated by a deterministic Turing Machine
problem has to be in both NP and NP-hard. with exponential time true.
(B) Correct because a NP Complete problem S is 2. Turing recongnizable language are “not” closed
polynomial time educable to R. under complementation. For any Turing
(C) Incorrect because Q is not in NP. recognizable language the Turing Machine ‘T’
(D) Incorrect because there is no NP-complete problem
recognizing ‘L’ may not terminate on inputs
that is polynomial time Turing-reducible to Q.
117. (a) x Ï L - False
118. (c) 3 SAT ® NP-complete problem 3. Turing decidable languages are CLOSED under
2 SAT ® P type problem union and complementation. It is easy to
119. (c) Since, 3 SAT is reduced to Õ, this implies 3 SAT £ determine if turing machine is decidable-True
Õ and since, Õ is reduced to 3 SAT, this implies So, answer is option (c) only 2.
p £ 3 SAT. 127. (c) According to the option, P2 is reducible to P3.
We know that, if L1 £ L2 and L1 is NP-complete, then Also it gives that P2 is undecidable.
L2 is also NP-complete. From (a) and (b) ;
Since, 3 SAT is NP-complete so Õ is also NP complete. P3 is undecidable.
120. (a) Consider the case where L = (0 + 1)* 128. (a) This turning machine starts at 90 if it doesn't get any
Here the answer of any turing machine would be yes input symbol but B then it stops.
since some output is displayed. So if (00 + 1) * is chosen then the M/C can halt.
Consider the case where L = f Option (b) is wrong.
Here, the answer of any turing machine would be Option (c) & (d) are possible but not necessary.
No since no output is displayed.
Option (a) (0 + 1) * 1 or more occurrence of 0 or 1.
This type of behaviour is displayed by the recursive
So 0, 1, 00, 01, 10, 11........are valid strings & the
language and therefore, the language L is recursive
machine doesn't halt for them.
language and therefore, the language L is recursive.
Hence (a) is correct option
Turing Machines 129. (b) Option (d) is incorrect as the problem is a decision
problem. Now, we need to check whether the
121. (a) A Turing Machine (M) is a recursive if F it halts for problem is decidable or not.
every input string either in accept or reject state. Here The problem is not decidable since the word wÎS.
a computable function is defined in simple way such Also, the problem is not completely undecidable
as { X # f ( X ) | X Î A*} since, the input and the state is given so after a
certain point of time the probability of finding out
So, f is computable if and only if Lf is recursive. the answer increases.
So, option (a) is correct.

You might also like