Professional Documents
Culture Documents
THEORY OF COMPUTATION
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
{ }
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]
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
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
1
0
1,0
q2 q0
0, 1
Second, (a + b)*
0
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