0% found this document useful (0 votes)
47 views38 pages

Unacademy Workbook Toc

The document contains a series of questions related to the Theory of Computation, focusing on topics such as finite state machines, regular languages, and automata theory. Each question presents a problem or statement that requires an understanding of computational concepts, often referencing specific GATE examinations. The content is structured in a quiz format, with multiple-choice answers provided for each question.

Uploaded by

Shivam Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views38 pages

Unacademy Workbook Toc

The document contains a series of questions related to the Theory of Computation, focusing on topics such as finite state machines, regular languages, and automata theory. Each question presents a problem or statement that requires an understanding of computational concepts, often referencing specific GATE examinations. The content is structured in a quiz format, with multiple-choice answers provided for each question.

Uploaded by

Shivam Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Theory of

Computation
1 DFA, NFA, Minimization Technique and
Product Automation

Q.1 The number of substrings (of all (C) The set of binary strings in which
lengths inclusive) that can be formed the number of zeros is the same as
from a character string of length n is the number of ones.
(A) n (B) n 2 (D) The set {1, 101, 11011, 1110111, …}
[GATE 1998 : IIT Delhi]
n(n  1) n(n  1)
(C) (D) 1 Q.6 How many substrings of different
2 2 lengths (non-zero) can be formed from
[GATE 1989 : IIT Kanpur] a character string of length n?
Q.2 State True or False with one line (A) n (B) n 2
explanation :
(C) 2 n (D) n(n+1)/2
A FSM (Finite State Machine) can be
designed to add two integers of any [GATE 1998 : IIT Delhi]
arbitrary length (arbitrary number of Q.7 Let L be the set of all binary strings
digits). whose last two symbols are the same.
[GATE 1994 : IIT Kharagpur] The number of states in the minimum
state deterministic finite-state
Q.3 Let L   * where   a,b which of
automaton accepting L is
the following is true? (A) 2 (B) 5
(A) L  {x x has an equal number of a’s (C) 8 (D) 3
and b’s} is regular [GATE 1998 : IIT Delhi]
(B) L  a n bn n  1 is regular Q.8 Consider the regular expression (0+1),
(0+1)….n times. The minimum state
(C) L  {x x has more a’s than b’s} is finite automaton that recognizes the
regular language represented by this regular
(D) L  a m bn m  1, n  1 is regular expression contains :
(A) n states
[GATE 1997 : IIT Madras]
(B) n +1 states
Q.4 Given   a,b , which one of the (C) n + 2 states
following sets is not countable. (D) None of the above
(A) Set of all strings over  [GATE 1999 : IIT Bombay]
(B) Set of all languages over  Q.9 What can be said about a regular
language L over {a} whose minimal
(C) Set of all regular language over 
finite state automaton has two states?
(D) Set of all languages over 
accepted by Turing machines. (A) L must be {a n nis odd}
[GATE 1997 : IIT Madras]
(B) L must be {a n nis even}
Q.5 Which of the following sets can be
recognized by a deterministic finite- (C) L must be {a n n  0}
state automaton?
(D) Either L must be {a n nis odd } or L
(A) The numbers 1, 2, 4, 8,…. 2 ,….. n

written in binary. must be {a n n is even}

(B) The numbers 1, 2, 4, … 2 n , …. [GATE 2000 : IIT Kharagpur]


written in unary.
Theory of Computation 1
Q.10 Consider the following two statements: (A) Does not form a group
S1 : 0 2n
n  1 is a regular language (B) Forms a non-commutative group
(C) Does not have a right identity
S2 : {0m1n 0m+n m  1and n  1} is a regular element
language (D) Forms a group if the empty string
Which of the following statements is is removed from  * .
correct?
[GATE 2003 : IIT Madras]
(A) Only S1 is correct Q.15 Consider the following deterministic
(B) Only S2 is correct finite state automation M.
(C) Both S1 and S2 are correct
(D) None of S1 and S2 is correct
[GATE 2001 : IIT Kanpur] Let S denote the set of seven bit binary
Q.11 Given an arbitrary non-deterministic strings in which the first, the fourth,
finite automaton (NFA) with N states, and the last bits are 1. The number of
the maximum number of states in an strings in S that are accepted by M is
equivalent minimized DFA is at least
(A) 1 (B) 5
(C) 7 (D) 8
(A) N 2 (B) 2N [GATE 2003 : IIT Madras]
(C) 2N (D) N! Q.16 Consider the NFA M shown below.
[GATE 2001 : IIT Kanpur]
Q.12 Consider a DFA over   {a, b} accepting
all strings which have number of a’s
divisible by 6 and number of b’s
divisible by 8. What is the minimum
number of states that the DFA will
have?
(A) 8 (B) 14 Let the language accepted by M be L.
(C) 15 (D) 48 Let L1 be the language accepted by the
[GATE 2001 : IIT Kanpur]
NFA, M 1 obtained by changing the
Q.13 Consider the following languages :
accepting state of M to a non-accepting
L1  {ww w {a, b}*}
state and by changing the non-
L2  {ww R w  {a, b}*, w Ris the reverse of w} accepting state of M to accepting
states. Which of the following
L3  {02i i is an integer} statements is true?
L4  {0i i is an integer} (A) L1  {0,1}*  L (B) L1  {0,1}*
2

Which of the languages are regular? (C) L1  L (D) L1  L


[GATE 2003 : IIT Madras]
(A) Only L1 and L2 Q.17 Consider the machine M :
(B) Only L2 , L3 and L4
(C) Only L3 and L4
(D) Only L3
[GATE 2001 : IIT Kanpur]
Q.14 Consider the set  * of all strings over
The language recognized by M is :
the alphabet   0,1   * with the
every a in wis followed
concatenation operator for strings (A) {w {a, b}*
by exactly twob ' s}

2 Theory of Computation
every a in wis followed Q.22 Given below are two finite state
(B) {w {a, b}* automata (  indicates the start state
by at least twob ' s}
and F indicates a final state)
wcontains the Y:
(C) {w {a, b}*
substring ' abb '} a b
1 1 2
{w {a, b}* wdoes not contain ' aa' 2(F) 2 1
(D) .
as a substring} Z:
[GATE 2005 : IIT Bombay] a b
1 1 2
Q.18 If s is a string over (0+1)* then let n0 ( s )
2(F) 2 1
denote the number of 0’s in s and n1 (s)
the number of 1' s in s. Which one of the Which of the following represents the
following languages is not regular? product automaton ZXY?

(A) L  {s  (0  1) * n0 (s)is a 3- digit prime}


L  {s  (0  1) * (A)
(B)
for every prefix s ' of s, n0 ( s ')  n1 ( s ')  2}

(C) L  {s  (0  1)* n0 (s ')  n1 (s)  4}


n0 ( s ) mod 7
(D) L  {s  (0  1) *
 n1 ( s ) mod 5  0}
[GATE 2006 : IIT Kharagpur] (B)
Q.19 Which of the following is TRUE?
(A) Every subset of a regular set is
regular
(B) Every finite subset of a non-regular
set is regular
(C) The union of two non-regular sets (C)
is not regular
(D) Infinite union of finite sets is
regular
[GATE 2007 : IIT Kanpur]
(D) None
Q.20 A minimum state deterministic finite
[GATE 2008 : IISc Bangalore]
automaton accepting the language
Q.23 Which of the following are regular sets?
w {0, 1}*,number of 0 ' s and1 ' s i n w
L  {w 1. {a nb2 m n  0, m  0}
are di vi si ble by 3 and 5,respect i vely}
2. {a nb 2 m n  2m}
has
(A) 15 states (B) 11 states 3. {a nb 2 m n  m}
(C) 10 states (D) 9 states 4.  xcy x, y  {a, b}*
Q.21 Which of the following languages is
(A) 1 and 4 only (B) 1 and 3 only
regular?

(C) 1 only (D) 4 only
(A) {ww w  {0,1} }
R
[GATE 2008 : IISc Bangalore]

(B) {ww x x, w  {0,1} }
R
Q.24 The below DFA accepts the set of all
strings over {0, 1} that
(C) {wxw
R
x, w  {0,1} }

(D) {xww x, w  {0,1} }
R

[GATE 2007 : IIT Kanpur]

Theory of Computation 3
(A) Begins either with 0 or 1
(B) End with 0
(C) End with 00
(C)
(D) Contains the substring 00.
[GATE 2009 : IIT Roorkee]
Q.25 Let w be any string of length n in {0,1}*.
Let L be the set of all substrings of w.
What is the minimum number of states
in a non-deterministic finite
(D)
automation that accepts L?
(A) n  1 (B) n
(C) n+1 (D) 2 n1
[GATE 2010 : IIT Guwahati] [GATE 2012 : IIT Delhi]
Q.26 Definition of the language L with Q.28 Which one of the following is TRUE?
alphabet {a} is given as following. (A) The language L  a n bn n  0 is
L  {a nk
k  0, and n is a positive integer regular.
constant} (B) The language L  a n n is prime is
What is the minimum number of states
regular.
needed in a DFA recognize L?
(C) The language
(A) k +1 (B) n + 1
 w has 3k+1 b's for 
(C) 2 n1 (D) 2 k 1  
L   w some k  N with  is regular.
[GATE 2011 : IIT Madras]   = a,b 
Q.27 Consider the set of strings on {0, 1} in  
which, every substring of 3 symbols has (D) The language
at most two zeros. For example, 001110 L  ww w  * with   0,1 is
and 011001 are in the language, but
regular.
100010 is not. All strings of length less
[GATE 2014 : IIT Kharagpur]
than 3 are also in the language. A
Q.29 Consider the finite automaton in the
partially completed DFA that accepts
following figure.
this language is shown below.

What is the set of reachable states for


the input string 0011?
(A) q0 , q1 , q2  (B) q0 , q1
(C) q0 , q1 , q2 , q3  (D)  q3 
[GATE 2014 : IIT Kharagpur]

The missing arcs in the DFA are Q.30 If L1  a n  0 and


n
L2  b n n  0 ,
consider
(i) L1  L2 is a regular language
(A)
(ii) L1  L2  a nb n n  0
Which one of the following is
CORRECT?
(A) Only (i)
(B) Only (ii)
(B) (C) Both (i) and (ii)
(D) Neither (i) nor (ii)
[GATE 2014 : IIT Kharagpur]

4 Theory of Computation
Q.31 Consider the DFAs M and N given Consider the language L1 (over alphabet
below. The number of states in a 0) accepted by the following
minimal DFA that accepts the automaton.
languages L( M )  L( N ) is _______. 0
0
0
[GATE 2015 : IIT Kanpur] The order of L1 is _______.
Q.32 The minimum possible number of [GATE 2018 : IIT Guwahati]
states of a deterministic finite Q.36 If L is a regular language over   {a, b}
automaton that accepts the regular
, which one of the following languages
language
is NOT regular?
L  {w1aw2 w1 , w2  {a, b}*, w1  2, w2  3}
is _______.

(A) L.LR  xy xL, y R L 
[GATE 2017 : IIT Roorkee] (B) ww R
w L
Q.33 Let  denote the transition function
and ̂ denote the extended transition
 x   * y *such 
(C) Prefix( L)   
function of the   NFA whose  that xy  L 
transition table is give below :  y  * y  
  a b (D) Suffix( L)   
 *such that xy  L 
 q0 q2  q1  q0 
[GATE 2019 : IIT Madras]
q1 q2  q2   q3  Q.37 Let  be the set of all bijections from
q2  q0    {1, ...., 5} to {1, ...., 5} , where id denotes
the identity function, i.e. id ( j )  j , j .
q3   q2  Let denote composition on functions.
For a string x  x1 x2 ..... xn   n , n  0 , let
Them ˆ ( q2 , aba ) is
( x)  x1 x2 ..... xn .
(A)  (B) {q0 , q1 , q3}
Consider the language
(C) q0 , q1 , q2  (D) q0 , q2 , q3  L   x  * ( x)  id  . The minimum
[GATE 2017 : IIT Roorkee] number of states in any DFA accepting
Q.34 Let N be an NFA with n states. Let k be L is _______.
the number of states of a minimal DFA [GATE 2019 : IIT Madras]
which is equivalent to N. Which one of Q.38 Which of the following statement is
the following is necessarily true? false?
(A) k  2 n (B) kn (A) Every finite subset of a non-regular
(C) k  n 2
(D) k  2 n set is regular
[GATE 2018 : IIT Guwahati] (B) Every subset of a regular set is
regular
Q.35 Given a language L, define Li as follows
: (C) Every finite subset of a regular set
is regular
L0  {}
(D) The intersection of two regular
Li  Li 1  L for all i  0 sets is regular
The order of a language L is defined as [GATE 1998 : IIT Delhi]
the smallest k such that Lk  Lk 1. Q.39 A deterministic finite automation (DFA)
D with alphabet   {a, b} is given below

Theory of Computation 5
The minimum number of states in a
DFA that accepts L is _______.
[GATE 2020 : IIT Delhi]
Q.41 Let R1 and R2 be regular sets defined
over the alphabet  then :
(A) R1  R2 is not regular
Which of the following finite state
(B) R1  R2 is regular
machine is a valid minimal DFA which
accepts the same language as D? (C)  *  R1 is regular

(D) R*1 is not regular


[GATE 1990 : IISc Bangalore]
(A) Q.42 The smallest finite automation which
accepts the language
L  {x length of x is divisible by 3} has
(A) 2 states (B) 3 states
(B) (C) 4 states (D) 5 states
[GATE 2002 : IISc Bangalore]
Q.43 The following finite state machine
accepts all those binary strings in
which the number of 1’s and 0’s are
(C) respectively

(D)

(A) Divisible by 3 and 2


[GATE 2019 : IIT Madras] (B) Odd and even
Q.40 Consider the following language. (C) Even and odd
(D) Divisible by 2 and 3
 x {a, b}* | number of 
a 'sin x is  [GATE 2004 : IIT Delhi]
 
L 
divisible by 2 but not 
divisible by 3 

Q.1 L = {Set of all strings over {a, b} ending Q.2 


L  an n  0 and n  2,5,7  which of
with fixed length symbol n}
the following options is/are TRUE about
Find minimum no. of states in DFA that L?
accept L?
(A) The minimum state DFA will
(A) 1 (B) n contain 8-states.
(C) n – 1 (D) n + 1 (B) No. of non-final state in minimum
DFA will be 3.
6 Theory of Computation
(C) No. of final states in minimum DFA Q.9 Which of the following options is/are
will be 6. true about above DFA.
(D) The language ‘L’ can be computed 1 0
1 0
by PDA. 0 0
Q.3 Find minimum no. of states in a DFA
that accept language. 1 1
(A) The language accepted by above
   
L  an n  0  bn n  1 _______? DFA is W 00W W {0,1}*
Q.4 L  W {0,1}* W mod n  k  where k (B) The minimum state DFA for M
consists of 3-states.
is positive integer constant and k  n .
(C) The regular expression for L ( M ) is
What is the no. of final states in
(0  1) *00 (0 1) *
minimum DFA?
(D) The language accepted y above
(A) n  1 (B) k
(B) k  1 (D) k  1 
DFA is W1 00W2 W1 and W2 {0,1} 
Q.5 L  W {0,1}* W mod n  k  where k Q.10 L  {W  {a, b}* # a (W ) mod 3  1 or
is positive integer constant and k  n . #b (W ) mod 4  1}
Which of the following options is/are Find no. of final sates in minimum DFA
TRUE about minimize DFA that accept that accept L?
L? Q.11 L  {W  {a, b}* # a (W ) mod 4  2 and
(A) No. of states in DFA is ( n  1). #b (W ) mod 5  1}
(B) No. of non-final states in DFA is Find no. of non-final sates in minimum
(n  k ). DFA?
(C) No. of final states is ( k  1). (A) The total no. of states in minimum
(D) The strings 1011101 is accepted by DFA will be 20.
DFA for n  5 and k  3. (B) The no. of final states in minimum
DFA will be 8.
Q.6 Find minimum no. of states for above
DFA _______? (C) The no. of non-final states in
0,1 minimum DFA is 14.
(D) The total no. of states in minimum
0,1 DFA is 16.
0
Q.12 NFA :
0,1 0,1

1 0,1 0 0

Which of the following options is/are


0,1 true?
Q.7 L  {W {a, b}n n is positive integer (A) L(NFA)  {W1 00 W2 W1 and W2  {0,1}*}
constant} (B) The complement of language accepted
Find minimum number of states in NFA by above NFA is {W 0 W  {0,1}*}.
that accept L?
(C) Conversion of above NFA into DFA will
(A) n  1 (B) n contain 4-states.
(C) n  1 (D) n  2 (D) The minimized DFA of above NFA will
Q.8 
L  WxW W , x {0,1}
R 
 Q.13
contain 3-states.
What will be ( A, 01) for the following
Find minimum number of states in DFA automation?
that accept L?

Theory of Computation 7
0 Q.16 Consider the non- deterministic finite
 automation (NFA) shown in the figure.
A B 1 State X is the starting state of the
automation. Let the language accepted
1 1 
D by the NFA with Y as the only accepting
state be L1. Similarly, let the language
C 0 accepted by the NFA with Z as the only
E
 accepting state be L2. Which of the
0 following statements about L1 and L2
(A) {D} (B) {B, D} is TRUE?
0
(C) {B, C , D} (D) {B, C , D, E}
0
Q.14 Consider following DFA:- Y
1
0 0 0,1
M: C E
0 0 1
1 X
1
Which of the following options is /are
TRUE? Z
(A) It accepts all the strings over {0, 1} 0 1
ending with 0. (A) L1  L2
(B) The regular expression for L ( M ) is (B) L1  L2
(1  01) (C) L2  L1
(C) It accepts set of all string over {0, (D) None of the above
1} having no two consecutive 0’ s. Q.17 If the final states and non-final states

(D) L( M )  {w{0,1} | ( w)is odd} in the DGA below are interchanged,
Q.15 Let M  ( K , , , s, F ) be a finite state then which of the following languages
over the alphabet {a, b} will be
automaton, where
accepted by the new DFA?
K  { A, B},   {a, b}, s  A, F  {B} , a
b
( A, a )  A,  ( A, b)  B, ( B, a ) a b
 B and ( B, b)  A
a
A grammar to generate the language b
accepted by M can be specified as
G  (V , , R, S ), where V  K  , and (A) Set of all strings that do not end
with ab
SA
(B) Set of all strings that begin with
Which one of the following set of rules
either an a or a b
will make L (G )  L ( M ) ?
(C) Set of all strings that do not
 A  aB, A  bA, B  bA contain the substring ab
(A  
 B  aA, B    (D) The set described by the regular
expression b * aa *(ba ) * b *
 A  aA, A  bB, B  aB 
(B)   Q.18 Consider the following two finite
 B  bA, B   
automata. M1 accepts L1 and M 2
 A  bB, A  aB, B  aA
(C)   accepts L2 which one of the following
 B  bA, B    is true?
 A  aA, A  bA, B  aB  0 0,1 0,1 0,1
(D)  
 B  bA, A  
1 1 1 1

0 M2
M1

8 Theory of Computation
(A) L1  L2 (B) L1  L2 (B) The set B, consisting of all strings
made up of only a’s and b’s having
(C) L1  L2   (D) L1  L2  L1 equal number of a’s and b’s defines
Q.19 Choose the correct statement – a regular language

 
(A) A  a nb n n  1, 2,3.... is regular (C) L( A * B) B gives the set A
language (D) None of the above

Classroom Practice Questions


1. D 2. TRUE 3. D 4. B 5. A
6. D 7. B 8. C 9. D 10. A
11. B 12. D 13. D 14. A 15. C
16. B 17. B 18. B 19. B 20. A
21. C 22. D 23. A 24. C 25. C
26. B 27. D 28. C 29. A 30. A
31. 1 32. 8 33. C 34. D 35. 2
36. B 37. 120 38. B 39. A 40. 6
41. B, C 42. 3 43. A
Practice Questions
1. D 2. B ,C, D 3. 4 4. C 5. B, D
6. 3 7. C 8. 7 9. B, C, D 10. 9
11. A, C 12. A, C, D 13. D 14. B, C 15. B
16. B 17. D 18. A 19. D



Theory of Computation 9
2 Regular Expression

Q.1 Let r  1(1  0)*, s  11*0 and t  1*0 be Q.6 Let S and T be languages over  = a, b
three regular expressions. Which one of represented by the regular expressions
the following is true? (a  b*) * and (a + b)*, respectively.
(A) L( s )  L(r ) and L( s )  L(t ) Which of the following is true?
(B) L(r )  L( s ) and L( s )  L(t )
(C) L( s )  L(t ) and L( s )  L(r ) (A) S  T
(D) L(t )  L( s ) and L( s )  L(r ) (B) T  S
(C) S  T
[GATE 1991 : IIT Madras]
Q.2 Which Two of the following four regular (D) S  T  
expressions are equivalent? [GATE 2002 : IISc Bangalore]
(i) (00) *(  0) Q.7 The regular expression 0*(10*)*
denotes the same set as
(ii) (00) *
(A) (1*0)*1*
(iii)
0*
(B) 0+ (0+10)*
(iv) 0 (00)*
(C) (0+1)* 10 (0+1)*
(A) (i) and (ii) (B) (ii) and (iii)
(D) None of the above
(C) (i) and (iii) (D) (iii) and (iv)
[GATE 2003 : IIT Madras]
[GATE 1996 : IISc Bangalore]
Q.8 Consider the regular language
Q.3 Which one of the following regular
L  (111  11111) * . The minimum
expressions over {0, 1} denotes the set
of all strings not containing 100 as a number of states in any DFA accepting
substring? this language is
(A) 0* (1+0)* (B) 0*1010* (A) 3 (B) 5
(C) 0*1*01* (D) 0*(10+1)* (C) 8 (D) 9
[GATE 1997 : IIT Madras] [GATE 2006 : IIT Kharagpur]
Q.4 If the regular set A is represented by Common Data for Q.9 & Q.10 Questions:
A  (01  1) * and the regular set ‘B’ is Consider the following finite state automaton
represented by B  ((01) *1*) * , which of
the following is true?
(A) A  B
(B) B  A
(C) A and B are incomparable
(D) A = B
[GATE 1998 : IIT Delhi] Q.9 The language accepted by this
Q.5 The string 1101 does not belong to the automaton is given by the regular
set represented by expression
(A) 110* (0+1) (A) b * ab * ab * ab * (B) (a  b) *
(B) 1(0+1)* 101 (C) b * a (a  b) * (D) b * ab * ab *
(C) (10)*(01)* (00 +11)* [GATE 2007 : IIT Kanpur]
(D) (00 + (11)* 0)* Q.10 The minimum state automation
[GATE 1998 : IIT Delhi] equivalent to the above FSA has the
following number of states

10 Theory of Computation
(A) 1 (B) 2 [GATE 2012 : IIT Delhi]
(C) 3 (D) 4 Q.14 Consider the languages L1   and
[GATE 2007 : IIT Kanpur]
L 2  a . Which one of the following
Q.11 Match the following NFA’s with the
regular expression they correspond to represents L1L*2  L*1 ?
(A)  (B) 
(C) a* (D) , a
[GATE 2013 : IIT Bombay]
Q. 15 The length of the shortest string NOT in
the language (over   a, b ) of the
following regular expression is _____.
a*b*(ba)*a*
[GATE 2014 : IIT Kharagpur]
Q. 16 Which of the regular expression given
below represent the following DFA?

1.   0(01*1  00) *01* 1. 0*1 (1+00*1*)*


2. 0*1*1+11*0*1
2.   0(10*1  00) *0
3. (0+1)*1
3.   0(10*1  10) *1 (A) 1 and 2 only (B) 1 and 3 only
4.   0(10*1  10)*10* (C) 2 and 3 only (D) 1, 2, and 3
(A) P  2, Q  1, R  3, S  4 [GATE 2014 : IIT Kharagpur]
Q. 17 Let L1  {w {0,1}* w has at least as
(B) P  1, Q  3, R  2, S  4
many occurrences of (110)’s as (011)’s}.
(C) P  1, Q  2, R  3, S  4
Let L2  {w {0,1}* w has at least as
(D) P  3, Q  2, R  1, S  4
many occurrences of (000)’s as (111)’s}.
[GATE 2008 : IISc Bangalore]
Which one of the following is TRUE?
Q. 12 Let L  {w  (0  1)* w has even number (A) L1 is regular but not L2
of 1’s}, i.e. L is the set of all bit strings
with even number of 1’s. Which one of (B) L2 is regular but not L1
the regular expressions below (C) Both L1 and L2 are regular.
represents L?
(D) Neither L1 nor L2 are regular
(A) (0*10*1)* (B) 0*(10* 10*)*
[GATE 2014 : IIT Kharagpur]
(C) 0*(10*1)*0* (D) 0*1(10*1)*10*
Q.18 Let L be the language represented by
[GATE 2010 : IIT Guwahati]
the regular expression  *0011  *
Q.13 What is the complement of the
language accepted by the NFA shown where   0,1 . What is the minimum
below? number of states in a DFA that
Assume   a and  is the empty recognizes L (complement of L)?
string. (A) 4 (B) 5
(C) 6 (D) 8
[GATE 2015 : IIT Kanpur]
Q.19 The number of states in the minimal
(A)  (B)  deterministic finite automaton

(C) a * (D) a, 


Theory of Computation 11
corresponding to the regular Q. 24 Consider the DFA A given below.
expression (0 +1)* (10) is _____.
[GATE 2015 : IIT Kanpur]
Q.20 Consider the alphabet   {0,1}, the
null/empty string  and the set of
strings X 0 , X1 , and X 2 generated by
the corresponding non-terminals of a
regular grammar X 0 , X1 , and X 2 are Which of the following are FALSE?
related as follows. 1. Complement of L(A) is context –
X 0  1 X1 free
2. L(A) = L((11*0+0)(0+1)*0*1*)
X1  0 X1  1 X 2
3. For the language accepted by A, A
X 2  0 X1  {} is the minimal DFA.
Which one of the following choices 4. A accepts all strings over {0, 1} of
precisely represents the strings in X 0 ? length at least 2.
(A) 10(0* + (10)*)1 (A) 1 and 3 only (B) 2 and 4 only
(B) 10(0*+(10*))*1 (C) 2 and 3 only (D) 3 and 4 only
(C) 1(0+10)*1 [GATE 2013 : IIT Bombay]
(D) 10(0+10)*1+110(0+10)*1 Q. 25 Consider the following two statements:
[GATE 2015 : IIT Kanpur] I. If all states of an NFA are accepting
states then the language accepted
Q.21 Which one of the following regular
by the NFA is  * .
expressions represents the language :
the set of all binary strings having two II. There exists a regular language A
consecutive 0’s and two consecutive such that for all languages B, A  B
1’s? is regular.
(0  1) *0011(0  1) * Which one of the following is
(A) CORRECT?
(0  1) *1100(0  1) *
(A) Only I is true
(0  1) *(00(0  1) *11 (B) Only II is true
(B)
11(0  1) *00)(1  1) * (C) Both I and II are true
(C) (0  1) *00(0  1) * (0  1) *11(0  1) * (D) Both I and II are false
(D) 00(0  1) *11  11(0  1) *00 [GATE 2016 : IISc Bangalore]
Q. 26 For   {a, b} , let us consider the
[GATE 2016 : IISc Bangalore]
Q.22 The number of states in the minimum regular language
sized DFA that accepts the language L  {x x  a 23k or x  b1012 k , k  0} . Which
defined by the regular expression one of the following can be a pumping
(0  1)*(0  1)(0  1)* is ______. length (the constant guaranteed by the
[GATE 2016 : IISc Bangalore] pumping lemma) for L?
Q.23 Consider the language L given by the (A) 3 (B) 5
regular expression (a+b)*b(a+b) over (C) 9 (D) 24
the alphabet {a, b}. The smallest [GATE 2019 : IIT Madras]
number of states needed in a Q. 27 Consider the following statements.
deterministic finite-state automaton I. If L1  L2 is regular, then both L1 and
(DFA) accepting L is ______.
[GATE 2017 : IIT Roorkee] L2 must be regular.
II.The class of regular languages is
closed under infinite union.
Which of the above statements is/are
TRUE?
12 Theory of Computation
(A) I only Q.30 The regular expression for the language
(B) II only recognized by the finite state
(C) Both I and II automation of the below figure is
(D) Neither I nor II ______.
[GATE 2020 : IIT Delhi]
Q.28 Which one of the following regular
expressions represents the set of all
binary strings with an odd number of [GATE 2002 : IISc Bangalore]
1’s? Q.31 Which one of the following languages
(A) ((0  1) *1(0  1) *1) *10* over the alphabet {0, 1} is described by
(B) (0*10*10*) *0*1 the regular expression (0 +1)* 0(0+1)*
0(0+1)*
(C) 10*(0*10*10*) *
(A) The set of all strings containing the
(D) (0*10*10*) *10* substring 00
[GATE 2020 : IIT Delhi] (B) The set of all strings containing at
Q.29 Which of the following regular most two 0’s
expression identities are true? (C) The set of all strings containing at
(A) r (*) = r* least two 0’s
(B) (r*s*)* = (r + s)* (D) The set of all strings that begin and
(C) (r  s)  r *  s * end with either 0 or 1
[GATE 2009 : IIT Roorkee]
(D) r * s*  r *  s *
[GATE 1992 : IIT Delhi]

Q.1 Which of the following options Which of the following regular


represents regular expression language represents above regular
accepted by above DFA ‘M’? expression?
0
1 0 
(A) L  1n n  0 
q0 q1 (B) L  1
n
n  0 and n  1, 2
0 (C) L  1
n
n  0 and n  1, 2,5,7 
(A) (0  1) *1
(D) L  1
n
n  0 and n  3, 4
(B) 0*1(0  00*1) *
Q.4 Regular expression
(C) (0  10*0) *10*
 (0  1) *(0  1)(0  1) * what is the
(D) 1(0  1) *
minimum no. of states in DFA that
Q.2 Which of the following language is/are accept above R.E. _______?
NOT regular? Q.5 The language accepted by above

(A) L  WxW W , x {0,1}*
R
 automaton is given by regular
expression

(B) L  WxW W , x {0,1}*  a a
b b


(C) L  WxW W , x {0,1} 
 q0 b q1 q2

 
a
(D) L  WW W {0,1}*
Q.3 R.E.  (111  1111)* q3

(A) a * b (a  b)*

Theory of Computation 13
(B) a * ba * bb * aa * defined by the regular expression R?
(C) a * b (a  bb * a ) * Edges labeled  denote transitions on
the empty string.
(D) a * b (bb  aa ) * a, b

Q.6 Which of the following two regular a, b a s1 a a s1 a


expression is/are equivalent? (A)
a
(B)
a
s0 b s3 a, b s0 b s3
(i) (00) *(0 ) (ii) (0  1) *1
b s2 b b s2 b
(ii) (0*1*)* (iv) (0  1) *
a, b
(v) 0*1(1  00*1) * (vi) (0*0*) *
a, b
(A) (iii) and (iv) (B) (i) and (vi)
a s1 a a s1 a
(C) (ii) and (v) (D) None (C) (D)

Q.7 Consider the regular expression. s0 b a s3 s0 b a s3

R=(a+b)*(aa+bb)(a+b)*. Which of the b s2 b b s2 b

following non- deterministic finite a, b a, b


automata recognizes the language

Classroom Practice Questions


1. A 2. C 3. D 4. D 5. C,D
6. C 7. A 8. D 9. C 10. B
11. C 12. B 13. B 14. C 15. 3
16. B 17. B 18. B 19. 3 20. C
21. B 22. 2 23. 4 24. D 25. C
26. D 27. D 28. D 29. B 30. 0*1*
31. C
Practice Questions
1. A, B 2. C, D 3. B 4. 2 5. C
6. A, B, C 7. A



14 Theory of Computation
3 Grammar, Language and it's Application

Q.1 If G is a context-free grammar and w is Which one of the following statements


a string of length n in L(G), how long is is FALSE?
derivation of w in G, if G is Chomsky (A) L2 is context-free
normal form?
(B) L1  L2 is context-free
(A) 2n (B) 2n + 1
(C) 2n – 1 (D) n (C) Complement of L2 is recursive
[GATE 1992 : IIT Delhi] (D) Complement of L1 is context-free
Q.2 Which of the following definitions
but not regular
below generates the same language as
[GATE 2013 : IIT Bombay]
L where L  {x n y n n  1}
Q.6 Which of the following languages is /are
(i) E  xEy xy regular?
(ii) xy ( x  xyy  ) L1 :{wxw R w, x  {a, b}* w , x  0, w R is the
  reverse of string w}
(iii) x y
L2 :{a nb m m  n and m, n  0}
(A) (i) only (B) (i) and (ii)
(C) (ii) and (iii) (D) (ii) only L3 :{a p b q c r p, q, r  0}
[GATE 1995 : IIT Kanpur]
(A) L1 and L3 only (B) L2 only
Q.3 Let L denote the language generated by
the grammar S  0S0 00 . Which of the (B) L2 and L3 only (D) L3 only
following is true? [GATE 2015 : IIT Kanpur]
(A) L = 0
 Q.7 Which of the following languages is

generated by the given grammar?
(B) L is regular but not 0
S  aS bS 
(C) L is context free but not regular
(D) L is not context free (A) a n b m n, m  0
[GATE 2000 : IIT Kharagpur]
(B) {w  a, b * w has equal number of
Q.4 Let L  L1  L2 , where L1 and L1 are
a’s and b’s}
languages defined as follows,
(C) {a n  0}  {b n  0}  {a b n  0}
n n n n

L1  {a b c a b m, n  0}
m m n n

L2  {a i b j c k i, j , k  0} (D) a, b *
[GATE 2016 : IISc Bangalore]
Then L is
(A) Not recursive Q.8 Language L1 is defined by the grammar:
(B) Regular S1  aS1b 
(C) Context free but not regular
Language L2 is defined by the grammar:
(D) Recursively enumerable but not
context free S2  abS2 
[GATE 2009 : IIT Roorkee] Consider the following statements :
Q.5 Consider the following languages P : L1 is regular
L1  {0 p1q 0r p, q, r  0}
Q : L2 is regular
L2  {0 p1q 0r p, q, r  0, p  r} Which one of the following is TRUE?
(A) Both P and Q are true
Theory of Computation 15
(B) P is true and Q is false terminals and Y is a non-terminal),
(C) P is false and Q is true is always regular.
(D) Both P and Q are false 4. The derivation trees of strings
[GATE 2016 : IISc Bangalore] generated by a context-free
Q.9 A context-free grammar is ambiguous grammar in Chomsky Normal form
if : are always binary trees.
(A) The grammar contains useless (A) 1, 2, 3 and 4
non-terminals. (B) 2, 3 and 4 only
(B) It produces more than one parse (C) 1, 3 and 4 only
tree for same sentence. (D) 1, 2 and 4 only
(C) Some production has two non- [GATE 2008 : IISc Bangalore]
terminals side by side on the right- Q.13 Match the following List-I with List-II
hand side. List-I
(D) None of the above. (E) Checking that identifiers are
[GATE 1987 : IIT Bombay] declared before their use
Q.10 FORTRAN is a : (F) Number of formal parameters in
(A) Regular language. the declaration of a function agrees
(B) Context free language. with the number of actual
(C) Context sensitive language. parameters in a use of that
(D) None of the above. function
[GATE 1987 : IIT Bombay] (G) Arithmetic expressions with
Q.11 Consider the following grammar G : matched pairs of parentheses
(H) Palindromes
S  bS aA b
List-II
A  bA aB (P) L  {a nb m c n d m n  1, m  1}
B  bB aS a
(Q) X  XbX XcX dXf g
Let Na (w) and Nb (w) denote the number
(R) L  {wcw w  (a b)*} (S)
of a’s and b’s in a string w respectively.
The language L(G)  {a, b} generated X  bXb cXc 
by G is Codes :
(A) {w N a ( w)  3 N b ( w)} (A) E  P, F  R, G  Q, H  S
(B) E  R, F  P, G  S , H  Q
(B) {w N b ( w)  3 N a ( w)}
(C) E  R, F  P, G  Q, H  S
(C) {w N a ( w)  3k , k  {0,1, 2,...}}
(D) E  P, F  R, G  S , H  Q
(D) {w N b ( w)  3k , k  {0,1, 2,...}} [GATE 2008 : IISc Bangalore]
[GATE 2004 : IIT Delhi] Q. 14 S  aSa bSb a b
Q. 12 Which of the following statements are The language generated by the above
true? grammar over the alphabets {a, b} is the
1. Every left-recursive grammar can set of
be converted to a right-recursive (A) All palindromes
grammar and vice-versa. (B) All odd length palindromes
2. All  -productions can be removed (C) Strings that begin and end with the
from any context-free grammar by same symbol
suitable transformations. (D) All even length palindromes
3. The language generated by a [GATE 2009 : IIT Roorkee]
context-free grammar all of whose Q.15 Consider the languages
productions are of the form X  w
L1  {0i1 j i  j}, L2  {0i1 j i  j},
or X  wY (where, w is a string of

16 Theory of Computation
L3  {0i1 j i  2 j  1}, (A) {(ab) n (cb) n n  1}
L4  {0i1 j i  2 j}, n m m mn
n, m1 , m2 ,
(B) {(ab) cb 1 cb 2 ...cb
Which one of the following statement ..., mn  1}
is true?
(C) {(ab) n (cb m ) n m, n  1}
(A) Only L2 is context free
(D) {(ab) n (cb n ) m m, n  1}
(B) Only L2 and L3 are context free
[GATE 2017 : IIT Roorkee]
(C) Only L1 and L2 are context free Q.19 Identify the language generated by the
(D) All are context free following grammar, where S is the start
[GATE 2010 : IIT Guwahati] variable.
Q.16 Which of the following languages are S  XY
context-free? X  aX a
L1  {a mb n a nb m m, n  1}
Y  aYb 
L2  {a mb n a mb n m, n  1} (A) {a mb n m  n, n  0}
L3  {a mb n m  2n  1} (B) {a mb n m  n, n  0}
(A) L1 and L2 only (B) L1 and L3 only (C) {a mb n m  n, n  0}
(C) L2 and L3 only (D) L3 only (D) {a mb n m  n, n  0}
[GATE 2015 : IIT Kanpur] [GATE 2017 : IIT Roorkee]
Q.17 Consider the following context-free Q. 20 If G is a grammar with productions
grammars :
S  SaS aSb bSa SS 
G1 : S  aS B, B  b bB
Where S is the start variable, then
G2 : S  aA bB, A  aA B  , B  bB  which one of the following string is not
Which one of the following pairs of generated by G?
languages is generated by G1 and G2 , (A) abab (B) aaab
(C) abbaa (D) babba
respectively?
[GATE 2017 : IIT Roorkee]
(A) {a mb n m  0 or n  0} and
Q.21 Consider the context-free grammar
{a mbn m  0 and n  0} over the alphabet {a, b, c} given below.
S and T are non-terminals.
(B) {a b m  0 and n  0} and
m n

G1 : S  aSb T , T  cT 
{a mbn m  0 or n  0}
(C) {a b m  0 or n  0} and
m n G2 : S  bSa T , T  cT 
{a mbn m  0 and n  0} The language L(G1 )  L(G2 ) is

(D) {a b m  0 and n  0} and


m n (A) Finite
(B) Not finite but regular
{a mbn m  0 or n  0} (C) Context free but not regular
[GATE 2016 : IISc Bangalore] (D) Recursive but not context free
Q.18 Consider the following context-free [GATE 2017 : IIT Roorkee]
grammar over the alphabet   {a, b, c} Q.22 Which one of following kinds of
with S as the start symbol : derivation is used by LR parsers?
S  abScT abcT (A) Leftmost
(B) Leftmost in reverse
T  bT b
(C) Rightmost
Which one of the following represents
(D) Rightmost in reverse
the language generated by the above
[GATE 2019 : IIT Madras]
grammar?

Theory of Computation 17
Q.23 Consider the grammar given below: Q.26 Consider the language
S  Aa L  {a | n  0} {a b | n  0} and
n n n
the
A  BD following statements.
B b  I. L is deterministic context-free.
D d  II. L is context-free but not
deterministic context-free.
Let a,b,d, and $ be indexed as follows: III. L is not LL(k) for any k.
a b d $
Which of the above statements is/are
3 2 1 0 TRUE?
Compute the FOLLOW set of the non- (A) I only (B) II only
terminal B and write the index values (C) I and III only (D) III only
for the symbols in the FOLLOW set in [GATE 2002 : IISc Bangalore]
the descending order. (For example, if
Q.27 Which of the following features cannot
the FOLLOW set is {a, b, d,$}, then the
be captured by context-free grammar?
answer should be 3210)
(A) Syntax of if-then-else statements
[GATE 2019 : IIT Madras]
(B) Syntax of recursive procedures
Q.24 Consider the augmented grammar
(C) Whether a variable has been
given below :
declared before its use
S'S
(D) Variable names of arbitrary length.
S  L id [GATE 2019 : IIT Madras]
L  L, S S Q.28 The lexical analysis for a modern
computer language such as java needs
Let I 0  CLOSURE({[S '  S ]}) . the power of which one of the following
The number of items in the set GOTO machine models in a necessary and
sufficient sense?
I 0 ,  is : ________.
(A) Finite state automata
[GATE 2019 : IIT Madras] (B) Deterministic pushdown automata
Q.25 The C language is (C) Non-deterministic pushdown
(A) A context free language automata
(B) A context sensitive language (D) Turing machine
(C) A regular language [GATE 2011 : IIT Madras]
(D) Parsable fully only by a Turing
machine
[GATE 2002 : IISc Bangalore]

Q.1 G : S  aS bA (D) L(G )  {W  {a, b}* #b (W ) mod 3  1}

A  aA bC  Q.2 G : S  AB BC
C  aC bS B  aAb 
Language accepted by above grammar A  aA a
is
(A) L(G )  (a  b) * C  bC a

(B) L(G )  {W  {a, b}* Number of b’s Language accepted by above grammar
is
are odd}
(C) L(G )  {W  {a, b}* #b (W ) mod 3  0}

(A) L(G)  a nbn n  1 

18 Theory of Computation

(B) L(G)  anbm n  m  (C) It is necessarily non- regular
(D) None of the above
(C) L(G)  a b
n m
m  n Common Data for Q.7 & Q.8 Questions:
Consider the context- free grammar
(D) L(G)  a b
n m
n  m EEE
Q.3 Which of the following CFLS is E  (E * E)
represented by following grammar? E  id
S  AB / CD Where E is the starting symbol, the set of
C  0C /  terminals is id , (, , ),* , and the set of non-
A  0 A1/ 
terminals is {E}.
D  1D2/ 
Q.7 Which of the following terminal strings
B  0B/  has more than one parse tree when
(A) {0 1 2 | i  j  k OR i  j  k}
i j k
parsed according to the above
grammar?
(B) {0 1 2 | i  j OR j  k}
i j k

(A) id  id  id  id
(C) {0 1 2 | i  j  k OR i  j  k}
i j k
(B) id  (id *(id * id ))
(D) None.
(C) (id *(id * id ))  id
Q.4 Consider the following grammar.
(D) ((id * id  id ) * id )
G1 : S  bA | aB
Q.8 For the terminal string with more than
A  aS | bAA | a one parse tree obtained as solution to
B  bS | bBB | b Q. 8A. How many parse trees are
G2 : S  aSbS | bSaS | possible?
(A) 5 (B) 4
Which one is /are TRUE?
(C) 3 (D) 2
(A) L(G1 )  L(G2 ) Q.9 Let L be a context-free language and
(B) L(G1 )  L(G2 ) M a regular language. Then the
language L  M is
(C) L(G1 )  L(G2 )  
(A) Always regular
(D) L(G2 ) {}  L(G1 ) (B) Never regular
Q.5 Consider following grammar:- (C) Always a deterministic context-
G :{ S  aA, free language
(D) Always a context-free language
A  aA | bA
Q.10 Consider an ambiguous grammar G
B  bB | cC | c and its disambiguated version D. Let
C  cC | c } the language recognized by the two
The L(G1 ) ? grammars be denoted by L (G ) and
      L ( D ) respectively.
(A) a b c (B) a a b c
   
(A) L ( D )  L (G ) (B) L( D )  L(G )
(C) a a bb c c (D) (a b c)
(C) L( D)  L(G ) (D) L ( D ) is empty
Q.6 Let L be a regular language and M be
Q.11 The two grammars given below
a context free language, both over the
generate a language over the alphabet
alphabet  . Let L and M denote the
c c
{x, y, z}
complements of L and M respectively.
G1: S  x | z | xS | zS | yB
Which of the following statements
about the language L  M is TRUE?
c c B  y | z | yB | zB
(A) It is necessarily regular but not G1: S  y | z | yS | zS | xB
necessarily context free B  y | yS
(B) It is necessarily context free
Theory of Computation 19
Which of the following choices Q.12 Consider the grammar
describes the properties satisfied by S  ABCc bc
the strings in these languages?
BA  AB
(A) G1: No y appears before any x
G2: Every x is followed by at least Bb  bb
one y Ab  ab
(B) G1: No y appears before any x Aa  aa
G2: No x appears before any y Which of the following sentence can
(C) G1: No y appears after any x be derived by this grammar?
G2: Every x is followed by at least (A) abc (B) aab
one y (C) abcc (D) abbc
(D) G1: No y appears after any x
G2: Every y is followed by at least
one x

Classroom Practice Questions


1. C 2. A 3. B 4. C 5. D
6. A 7. D 8. C 9. B 10. B
11. C 12. C 13. C 14. B 15. D
16. B 17. D 18. B 19. C 20. C
21. B 22. D 23. 31 24. 5 25. B
26. C 27. C 28. A
Self - Practice Questions
1. D 2. D 3. A 4. B 5. C
6. A 7. A 8. A 9. D 10. C
11. A 12. A



20 Theory of Computation
4 Push Down Automata

Q.1 Context free languages and regular LE the set of all languages accepted by
languages are both closed under the empty stack. Which of the following is
operation(s) of : true?
(A) Union
(A) LD  LE
(B) Intersection
(C) Concatenation (B) LD  LE
(D) Complementation (C) LD  LE
[GATE 1989 : IIT Kanpur] (D) None of the above
Q.2 Context-free languages are [GATE 1999 : IIT Bombay]
(A) Closed under union
Q.7 If L1 is a context free language and L2
(B) Closed under complementation
is a regular language which of the
(C) Closed under intersection
following is/are false?
(D) Closed under Kleene closure.
(A) L1  L2 is not context free
[GATE 1992 : IIT Delhi]
Q.3 If L1 and L2 are context free (B) L1  L2 is context free
languages and R is a regular set, one (C) L1 is context free
of the languages below is not (D) L2 is regular
necessarily a context free language.
Which one? [GATE 1999 : IIT Bombay]
Q.8 Which of the following statement is
(A) L1L2 (B) L1  L2
true?
(C) L1  R (D) L1  L2 (A) If a language is context free it can
[GATE 1996 : IISc Bangalore] always be accepted by
Q.4 Which of the following languages over deterministic pushdown
{a, b, c} is accepted by a deterministic automaton
push down automata? (B) The union of two context free
(A) {wcwR w {a, b}*} languages is context free
(C) The intersection of two context
(B) {wwR w {a, b, c}*} free languages is context free
(C) {a nb n c n n  0} (D) The complement of a context free
language is context free
(D) {w w is a palindrome over {a, b, c}}
[GATE 2001 : IIT Kanpur]
[GATE 1997 : IIT Madras] Q.9 The language accepted by a Pushdown
Q.5 Context free languages are closed Automation in which the stack is
under : limited to 10 items is best described
(A) Union, intersection as
(B) Union, Kleene closure (A) Context free
(C) Intersection, complement (B) Regular
(D) Complement, Kleene Closure (C) Deterministic Context Free
[GATE 1999 : IIT Bombay] (D) Recursive
Q.6 Let LD be the set of all languages [GATE 2002 : IISc Bangalore]
accepted by a PDA by final state and

Theory of Computation 21
Q.10 Let G  ({S },{a, b}, R, S ) be a context (B) D f  N f and Dp  N P
free grammar where the rule set R is (C) D f  N f and Dp  N P
S  aSb S S  (D) D f  N f and Dp  N P
Which of the following statements is
[GATE 2005 : IIT Bombay]
true?
Q.14 Consider the languages :
(A) G is not ambiguous
L1  {a nb n c m n, m  0} and
(B) There exist x, y  L (G ) such that
xy  L(G ) L2  {a nb n c m n, m  0}
(C) There is a deterministic pushdown Which one of the following statement
automaton that accepts L (G ) is FALSE?
(D) We can find a deterministic finite (A) L1  L2 is a context-free language
state automaton that accepts (B) L1  L2 is a context-free language
L (G )
(C) L1 and L2 are context-free
[GATE 2003 : IIT Madras]
languages
Q.11 The language {a mb n c m  n m, n  1} is
(D) L1  L2 is a context sensitive
language
(A) Regular
[GATE 2005 : IIT Bombay]
(B) Context free but not regular
Q.15 Consider the languages :
(C) Context sensitive but not context
free L1  {w wR w {0,1}*}
(D) Type-0 but not context sensitive L2  {w # wR w {0,1}*} where # is
[GATE 2004 : IIT Delhi] a special symbol
Q.12 Let M  ( K , , F ,  , S , F ) be a L3  {w w w {0,1}*}
pushdown automaton. Which one of the following is TRUE?
Where, K= {s, f}, F = {f},
(A) L1 is a deterministic CFL
  {a, b}, F  {a} and
(B) L2 is a deterministic CFL
  {(( s, a, ), ( s, a)),
(( s, b, ), ( s, a)), (( s, a, ), (C) L3 is a CFL, but not a deterministic
CFL
( f , )), (( f , a, a), ( f , )),
(D) L3 is a deterministic CFL
(( f , b, a), ( f , ))}.
[GATE 2005 : IIT Bombay]
Which one of the following strings is
Let L1  0 1 0 n, m  0 ,
nm n m
not a member of L(M) ? Q.16
(A) aaa (B) aabab
L2  0n  m1n  m 0m n, m  0 , and
(C) baaba (D) bab
[GATE 2004 : IIT Delhi] L3  0n  m1n  m 0n  m n, m  0
Q.13 Let N f and N p denote the classes of Which of these languages are NOT
languages accepted by non- context free?
deterministic finite automata and (A) L1 only (B) L3 only
non-deterministic push-down (C) L1 and L2 (D) L2 and L3
automata, respectively. Let D f and D p
[GATE 2006 : IIT Kharagpur]
denote the classes of languages
Q.17 Consider the following statements
accepted by deterministic finite
about the context-free grammar
automata and deterministic push-
G  {S  SS , S  ab, S  ba, S  }
down automata, respectively. Which
one of the following is TRUE? 1. G is ambiguous
(A) D f  N f and Dp  N P 2. G produces all strings with equal
number of a’s and b’s
22 Theory of Computation
3. G can be accepted by a Here, w is the reverse of the string w.
r

deterministic PDA. Which of these language are


Which combination below expresses deterministic context-free languages?
all the true statements about G? (A) None of the languages
(A) 1 only (B) 1 and 3 only (B) Only L1
(C) 2 and 3 only (D) 1, 2 and 3
[GATE 2006 : IIT Kharagpur] (C) Only L1 and L2

Q.18 The language L  {0i 2i1i i  0} over the (D) All the three languages.
[GATE 2011 : IIT Madras]
alphabet {0, 1, 2} is
Q.22 Consider the NPDA
(A) Not recursive.
(B) Is recursive and is a deterministic (Q  {q0 , q1 , q2 },   {0,1},
CFL.   {0,1, }, , q0 ,
(C) Is a regular language. , F  {q2 }),
(D) None
where (as per usual convention) Q is
[GATE 2007 : IIT Kanpur]
the set of states,  is the input
Q. 19 Which one of the following is FALSE?
alphabet,  is the stack alphabet,  is
(A) There is a unique minimal DFA for
the state transition function, q0 is the
every regular language
(B) Every NFA can be converted to an initial state,  is the initial stack
equivalent PDA symbol, and F is the set of accepting
(C) Complement of every context free states. The state transition is as
language is recursive follows :
(D) Every non deterministic PDA can
be converted to an equivalent
deterministic PDA
[GATE 2009 : IIT Roorkee]
Q.20 Consider the languages L1 , L2 and L3 as
given below. Which one of the following sequences
L1  {0 p1q p, q  N } must follow the string 101100 so that
the overall string is accepted by the
L2  {0 p1q p, q  N and p  q} and automaton?
L3  {0 p1q 0r p, q, r  N and p  q  r} (A) 10110 (B) 10010
Which of the following statements is (C) 01010 (D) 01001
not TRUE? [GATE 2015 : IIT Kanpur]
(A) Pushdown automata (PDA) can be Q.23 Consider the transition diagram of a
PDA given below with input alphabet
used to recognize L1 and L2
  {a, b} and stack alphabet
(B) L1 is a regular language
  { X , Z } . Z is the initial stack
(C) All the three languages are symbol. Let L denote the language
context free accepted by the PDA.
(D) Turing machines can be used to
recognize all the languages.
[GATE 2011 : IIT Madras]
Q.21 Consider the following languages over
the alphabet   {0,1, c}:
Which one of the following is TRUE?
L1  {0n1n n  0}
(A) L  a nb n n  0 and is not
L2  {wcwr w {0,1}*}
accepted by any finite automata
L3  {wwr w {0,1}*}

Theory of Computation 23
(B) L  a n n  0  a nb n n  0 and is L1  {a p p is a prime number}
not accepted by any deterministic L2  {a nb m c 2 m n  0, m  0}
PDA
(C) L is not accepted by any Turning L3  {a nb n c 2 n n  0}
machine that halts on every input L4  {a nb n n  1}
(D) L  a n n  0  a nb n n  0 and is Which of the following are CORRECT?
deterministic context-free I. L1 is context free but not regular
[GATE 2016 : IISc Bangalore]
II. L2 is not context –free.
Q.24 Consider the following languages :
L1  {a nb m c n  m m, n  1} III. L3 is not context-free but
recursive
L2  {a nb n c 2 n n  1}
IV. L4 is deterministic context-free
Which one of the following is TRUE?
(A)I, II and IV only
(A) Both L1 and L2 are context free.
(B)II and III only
(B) L1 is context free while L2 is not (C)I and IV only
context free. (D)III and IV only
(C) L2 is context free while L1 is not [GATE 2017 : IIT Roorkee]
context free. Q.28 Consider the following languages :
(D) Neither L1 nor L2 is context free. a mb n c p d q | m  p  n  q, 
I.  
[GATE 2016 : IISc Bangalore]  where m, n, p, q  0 
Q.25 Let L1 , L2 be any two context-free a mb n c p d q | m  n and p  q, 
II.  
languages and R be any regular  where m, n, p, q  0 
language. Then which of the following
is/are CORRECT? a mb n c p d q | m  n  p and p  q, 
III.  
(i) L1  L2 is context free  where m, n, p, q  0 
(ii) L1 is context free  a mb n c p d q | mn  p  q, 
IV.  
(iii) L1  R is context free  where m, n, p, q  0 
Which of the languages above are
(iv) L1  L2 is context free
context-free?
(A) (i), (ii) and (iv) only (A) I and IV only (B) I and II only
(B) (i) and (iii) only (C) II and III only (D) II and IV only
(C) (ii) and (iv) only [GATE 2018 : IIT Guwahati]
(D) (i) only Q.29 Which one of the following languages
[GATE 2017 : IIT Roorkee] over   {a, b} is NOT context-free?
Q.26 Consider the following language over
(A) {ww w  {a, b}*}
R
the alphabet   {a, b, c} .
(B) {wa b w w  {a, b}*, n  0}
n n R
Let L1  {a nb n c m m, n  0} and
L2  {a mb n c n m, n  0} . (C) {wa w b w  {a, b}*, n  0}
n R n

Which of the following are context- (D) {a b i  {n,3n,5n}*, n  0}


n i

free languages?
[GATE 2019 : IIT Madras]
I. L1  L2 II. L1  L2
Q.30 Consider the following languages.
(A) I only (B) II only
L1  {wxyx | w, x, y (0  1)  }
(C) I and II (D) Neither I nor II
[GATE 2017 : IIT Roorkee] L2   xy | x, y (a  b)*, x  y , x  y
Which one of the following is TRUE?
Q.27 Consider the following languages.

24 Theory of Computation
(A) L1 is regular and L2 is context-free. (C) Neither L1 nor L2 is context-free.
(B) L1 is context-free but not regular (D) L1 is context-free but L2 is not
and L2 is context-free. context-free.
[GATE 2020 : IIT Delhi]

Q.1 Which of the following language can’t Q.6 Which of the following options is/are
be solved by deterministic PDA? TURE?


(A) L  a b n  1
n n
 (A) L  {ai b j | i  0, j  n2 } is not CFL
(B) For grammar G  {S  a S b | SS |}
(B) L  a b c n  0 and m  1
n m m
The L (G ) can be solved by DPDA.

(C) L  a b n  0  a b n  0
n n n 2n (C) L  {w x n wR y n | w{x, y}} is CRL.
(D) For L  {ww | w {a, b}}, L is not
(D) L  a b n  m
n m
CFL.
Q.2 Which of the following options OR Q.7 Consider the regular grammar below
statement is/ are correct/ S  bS | aA | 
S1:{a nbn cm | n  m  2n} is CFL A  aS | bA
S1:{ai b j | i  j OR i  2 j} is DCFL. The Myhill- Nerode equivalence
(A) S1 only (B) S 2 only classes for the language generated by
the grammar are
(C) Both (D) None.
Q.3 Consider the following grammar:- {w (a  b)* | #a ( w)is even}and 
(A)  
G1 : S  a S a | a {w (a  b) | #a ( w)is odd}
*

G2 : S  a S a | b {w (a  b) | #b ( w)is even}and 
*

Which of the options is / are TRUE (B)  


{w (a  b) | #b ( w)is odd} 
*

(A) L(G1 ) and L(G2 ) are regular


{w  (a  b)* | #a ( w)  # a (w)} 
(B) L(G1 )is regular but L(G2 )is CFL  
(C) and (w  (a  b)* |#a (w)is even}and 
(C) Both L(G1 ) and L(G2 ) are CFL  
{w (a  b) | #a ( w)  #b ( w)}
*
(D) L(G2 )is regular but L(G1 )is CFL 
Q.4 Equivalent CFL for  wa | w (a  b)* and 
(D) {},  
G  {S  a S | a S b S |}  wb | w(a  b)
*

(A) L  { X | X is a palindromes} Q.8 Consider the pushdown automaton
(B) L  { X | X  a b V n  0}
n n (PDA) below which runs over the input
alphabet (a, b, c). It has the stack
(C) L  { X | each prefix oF ‘X’ has
alphabet {Z 0 , X } where Z 0 is the
atleast as many a’ s as b’s}
bottom-of-stack market. The set of
(D) L  { X | X has equal no. of a’s and
states of the PDA is {s, t, u, f} where s
b’s} is the start and f is the final state. The
Q.5 Which of the following options is/are PDA accepts by final state. The
CFL? transitions of the PDA given below are
(A) L  {ww | w {a, b}} depicted in a standard manner. For
(B) L  {w1w2 | w1  w2 and w1 , w2 {a, b}} example, the transition
(s, b, X )  (t , XZ0 ) means that if the
(C) L  {a nbmc n d m | n, m  0}
PDA is in state a and the symbol on
(D) L  {x w y w | a, y, w {a, b} } the top of the stack is X, then it can

Theory of Computation 25
read b from the input and move to Q.10 Which of the following languages is
state t after popping the top of stack accepted by a non-deterministic
and pushing the symbols Z 0 and X (in pushdown automaton (PDA) but NOT
that order) on the stack. by a deterministic PDA?

(s, a, Z0 )  (s, XXZ0 ) (A) {a nbn cn | n  0}


(B) {a bmc n |  m or m  n}
( s, , Z0 )  ( f , )
(C) {a b | n  0}
n n
( s, a, X )  ( s, XXX )
(D) {a b | m, n  0}
m n
( s, b, X )  (t , )
(t , b, X )  (t , ) Q.11 Consider the following languages.

(t , c, X )  (u , ) L1  ai b j c k | i  j , k  1
(u , c, X )  (u, ) L1  aib j | j  2i, i  0
(u, , Z0 )  ( f , ) Which of the following is true?
The language accepted by the PDA is (A) L1 is not a CFL but L2 is
(A) a b c |  m  n
m n (B) L1  L2   and L1 is non-regular
(C) L1  L2 is not a CFL but L2
(B) a b c |  m
m n

(D) There is a 4-state PDA that


(C) a b c | 2  m  n
m n
accepts L1' but there is no DPDA
(D) a b c | m  n
m n
that accepts L2
Q.9 In the context-free grammar below, S Q.12 Which of the following languages is
is the start symbol, a and b are (are) non-regular?
terminals, and  denotes the empty L1  {0m1n | 0  m  n  10000}
string. L2  {w | w reads the same forward and
S  aSAb | 
backward}
A  bA |  L3  {w{0,1}* | w contains an even
The grammar generates the language number of 0’s and an even number of
 (a  b) b  a b | m  n
*
(A) *
(B) m n 1’s}
(A) L2 and L3 only (B) L1 and L2 only
(C) a b | m  n
m n
(D) a*b*
(C) L3 only (D) L2 only

Classroom Practice Questions


1. A, C 2. A, D 3. B 4. A 5. B
6. A 7. A 8. B 9. B 10. C
11. B 12. B 13. D 14. A 15. B
16. D 17. B 18. D 19. D 20. D
21. C 22. B 23. D 24. B 25. B
26. A 27. D 28. B 29. C 30. A
Practice Questions
1. C 2. D 3. B 4. C 5. B, D
6. A, C 7. A 8. C 9. B 10. B
11. B 12. D



26 Theory of Computation
5 TM and Un-Decidability

Q.1 Let L1 be a recursive language. Let L 2 (B) Always recognizable by pushdown


automata.
and L3 be languages that are
(C) Also called type (0) languages.
recursively enumerable but not (D) Recognizable by Turing machines.
recursive. Which of the following [GATE 1990 : IISc Bangalore]
statement is not necessarily true? Q.5 In which of the cases stated below is
(A) L2  L1 is recursively enumerable the following statement true?
“For every nondeterministic machine
(B) L1  L3 is recursively enumerable.
M 1 there exists an equivalent
(C) L2  L3 is recursively enumerable.
deterministic machine M 2 recognizing
(D) L2  L3 is recursively enumerable.
the same language”.
[GATE 2010 : IIT Guwahati] (A) M 1 is nondeterministic finite
Q.2 Consider the following decision
automation
problems :
(B) M 1 is a nondeterministic PDA
P1 : Does a given finite state machine
(C) M 1 is a nondeterministic Turing
accept a given string.
machine
P1 : Does a given context free grammar
(D) For no machine M 1 use the above
generate an infinite number of strings.
statement true
Which of the following statement is
[GATE 1992 : IIT Delhi]
true?
Q.6 Which of the following conversions is
(A) Both ( P1 ) and ( P2 ) are decidable not possible (algorithmically)?
(B) Neither ( P1 ) nor ( P2 ) are decidable (A) Regular grammar to context-free
grammar
(C) Only ( P1 ) is decidable
(B) Non-deterministic FSA to
(D) Only ( P2 ) is decidable deterministic FSA
[GATE 2000 : IIT Kharagpur] (C) Non-deterministic PDA to
Q. 3 Which of the following statement is deterministic PDA
false? (D) Non-deterministic Turing machine
to deterministic Turing machine.
(A) Every NFA can be converted to an
[GATE 1994 : IIT Kharagpur]
equivalent DFA.
Q.7 Which one of the following is not
(B) Every non-deterministic Turing
decidable?
machine can be converted to an
(A) Given a Turing machine M, a string
equivalent deterministic Turing
s and an integer k, M accepts s
machine.
within k steps
(C) Every regular language is also a
(B) Equivalence of two given Turing
context free language.
machines
(D) Every subset of a recursively (C) Language accepted by a given
enumerable set is recursive. finite state machine is non empty
[GATE 2007 : IIT Kanpur] (D) Language generated by a context
Q.4 Recursive languages are : free grammar is non empty
(A) A proper superset of context free [GATE 1997 : IIT Madras]
languages.

Theory of Computation 27
Q.8 Regarding the power of recognition of 0 1 B
languages, which of the following q0 q1 ,1, R q11, R Halt
statement is false?
q1 q1 ,1, R q1 ,1, R q 0 ,B,L
(A) The non-deterministic finite-state
automata are equivalent to The table is interpreted as illustrated
deterministic finite-state below.
automata. The entry ( q1 ,1, R ) in row q 0 and
(B) Non- deterministic Push-down column 1 signifies that if M is in state
automata are equivalent to
q 0 and reads 1 on the current tape
deterministic Push-down
automata. square, then it writes 1 on the same
(C) Non-deterministic Turing tape square, moves its tape head one
machines are equivalent to position to the right and transitions to
deterministic Turing machines. state q1 . Which of the following
(D) Multi-tape Turing machines are statement is true about M?
equivalent to single-tape Turing (A) M does not halt on any string in
machines. (0  1)
[GATE 1998 : IIT Delhi] (B) M does not halt on any string in
Q.9 Which of the following is true? (00 + 1)*
(A) The complement of a recursive (C) M halts on all string ending in a 0
language is recursive. (D) M halts on all string ending in a 1
(B) The complement of a recursively [GATE 2003 : IIT Madras]
enumerable language is Q.12 Let L1 be a recursive language, and let
recursively enumerable.
(C) The complement of a recursive L 2 be a recursive enumerable but not
language is either recursive or a recursive language. Which one of the
recursively enumerable. following is TRUE?
(D) The complement of a context-free (A) L1 is recursive and L 2 is
language is context-free. recursively enumerable
[GATE 2002 : IISc Bangalore]
(B) L1 is recursive and L 2 is not
Q.10 If the strings of a language L can be
recursively enumerable
effectively enumerated in
lexicographic (i.e. alphabetic) order, (C) L1 and L 2 are recursively
which of the following statements is enumerable
true? (D) L1 is recursively enumerable and
(A) L is necessarily finite
L 2 is recursive
(B) L is regular but not necessarily
finite [GATE 2005 : IIT Bombay]
(C) L is context free but not Q.13 For s  (0  1) * , let d(s) denote the
necessarily regular decimal value of s (e. g. d (101) = 5)
(D) L is recursive but not necessarily Let L = {s  (0 + 1)* d(s) mod 5 = 2
context free and d(s) mod 7  4}
[GATE 2003 : IIT Madras]
Which one of the following statement
Q.11 A single tape Turing Machine M has is true?
two states q0 and q1 of which q0 is the (A) L is recursively enumerable, but
starting state. The tape alphabet of M not recursive
is {0, 1, B} and its input alphabet is (B) L is recursive, but not context
{0,1}. The symbol B is the blank symbol free
used to indicate end of an input string. (C) L is context free, but not regular
The transition function of M is (D) L is regular
described in the following table. [GATE 2006 : IIT Kharagpur]
28 Theory of Computation
Q.14 Let L1 be a regular language, L 2 be a Q.18 Let L be a language and L be its
deterministic context-free language complement. Which one of the
and L3 be a recursively enumerable, following is NOT a viable possibility?
but not recursive language. Which one (A) Neither L nor L is recursively
of the following statement is false? enumerable (r.e.).
(A) L1  L 2 is a deterministic CFL (B) One of L and L is r.e. but not
recursive; the other is not r.e.
(B) L3  L1 is recursive
(C) Both L and L are r.e. but not
(C) L1  L 2 is context free recursive.
(D) L1  L2  L3 is recursively (D) Both L and L are recursive.
enumerable [GATE 2014 : IIT Kharagpur]
[GATE 2006 : IIT Kharagpur]
Q.15 Which of the following is true for the Q.19 Let  M  be the encoding of a Turing
language {a p p is prime} ? machines as a string over   0,1 .
(A) It is not accepted by a Turing Let L={  M  M is a Turing machine
machine that accepts a string of length {2014}.
(B) It is regular but not context-free Then, L is
(C) It is context-free but not regular (A) Decidable and recursively
(D) It is neither regular nor context- enumerable
free, but accepted by a Turing (B) Un-decidable but recursively
machine enumerable
[GATE 2008 : IISc Bangalore] (C) Un-decidable and not recursively
Q.16 If L and L are recursively enumerable enumerable
then L is (D) Decidable but not recursively
(A) Regular enumerable
(B) Context free [GATE 2014 : IIT Kharagpur]
(C) Context sensitive Q.20 For any two languages L1 and L2 such
(D) Recursive that L1 is context-free and L2 is
[GATE 2008 : IISc Bangalore]
recursively enumerable but not
Q.17 Which of the following statement
recursive, which of the following is /
is/are FALSE?
are necessarily true?
1. For every non-deterministic
Turing machine, there exits an I. L1 (complement of L1 ) is recursive
equivalent deterministic Turing II. L2 (complement of L2 ) is
machine recursive
2. Turing recognizable languages are
III. L1 is context-free
closed under union and
complementation IV. L1  L2 is recursively enumerable
3. Turing decidable languages are (A) I only
closed under intersection and (B) III only
complementation (C) III and IV only
4. Turing recognizable languages are (D) I and IV only
closed under union and
[GATE 2015 : IIT Kanpur]
intersection
Q.21 Consider the following types of
(A) 1 and 4 only (B) 1 and 3 only
languages :
(C) 2 only (D) 3 only
L1 : Regular, L2 : Context-free,
[GATE 2013 : IIT Bombay]
L3 : Recursive,

Theory of Computation 29
L4 : Recursively enumerable. (B) II and III only
Which of the following is/are TRUE? (C) II, III and IV only
(D) III and IV only
I. L3  L4 is recursively enumerable
[GATE 2017 : IIT Roorkee]
II. L2  L3 is recursive Q.24 The set of all recursively enumerable
languages is
III. L  L2 is context-free
*
1
(A) closed under complementation.
IV. L1  L2 is context-free (B) closed under intersection.
(A)I only (C) a subset of the set of all recursive
(B)I and III only languages.
(C)I and IV only (D) an uncountable set.
(D)I, II and III only [GATE 2018 : IIT Guwahati]
[GATE 2016 : IISc Bangalore] Q.25 Consider the following problems.
Q.22 Consider the following languages. L (G ) denotes the language generated
L1  { M  M takes at least 2016 by a grammar G. L ( M ) denotes the
steps on some input}, language accepted by a machine M.
(I) For an unrestricted grammar G
L2  { M  M takes at least 2016
and a string w, whether w  L (G )
steps on all inputs} and
(II) Given a Turning machine M,
L3 = {<M> M accepts  }, whether L ( M ) is regular
Where for each Turing machine M, <M> (III) Given two grammars G1 and G2 ,
denotes a specific encoding of M.
whether L(G1 )  L(G2 )
Which one of the following is TRUE?
(A) L1 is recursive and L 2 , L3 are not (IV) Given an NFA N, whether there is
a deterministic PDA P such that N
recursive
and P accept the same language.
(B) L 2 is recursive and L1 , L3 are not Which one of the following statements
recursive is correct?
(C) L1 , L2 are recursive and L3 is not (A) Only I and II are undecidable
recursive (B) Only III is undecidable
(D) L1 , L2 , L3 are recursive (C) Only II and IV are undecidable
(D) Only I, II and III are undecidable
[GATE 2016 : IISc Bangalore]
[GATE 2018 : IIT Guwahati]
Q.23 Let L(R) be the language represented
Q.26 Which of the following problems are
by regular expression R. Let L(G) be
un-decidable?
the language generated by a context
(A) Membership problem in context-
free grammar G. Let L(M) be the
free languages.
language accepted by a Turing
(B) Whether a given context-free
machine M.
language is regular.
Which of the following decision
(C) Whether a finite state automation
problems are undecidable?
halts on all inputs.
I. Given a regular expression R and a
(D) Membership problem for type 0
string w, is w  L(R)?
languages
II. Given a context free grammar G, is
[GATE 1989 : IIT Kanpur]
L(G) =  ?
Q.27 It is undecidable whether :
III. Given a context free grammar G, is
(A) An arbitrary Turing machine halts
L(G) =  * for some alphabet  ?
after 100 steps.
IV. Given a Turing machine M and a (B) A Turing machine prints a specific
string w, is w  L(M)? letter.
(A) I and IV only

30 Theory of Computation
(C) A Turing machine computes the 4. If L is a recursive language, then
product of two numbers. is L also recursive?
(D) None of the above. (A) 1, 2,3, 4 (B) 1, 2
[GATE 1990 : IISc Bangalore]
(C) 2,3, 4 (D) 3, 4
Q.28 Which one of the following is the
strongest correct statement about a [GATE 2012 : IIT Delhi]
finite language over some finite Q.32 Which of the following is/are
alphabet  ? undecidable?
(A) It could be un-decidable 1. G is a CFG. Is L (G )   ?
(B) It is Turing-machine recognizable 2. G is a CFG. Is L(G )   * ?
(C) It is a regular language 3. M is a Turing machines. Is L ( M )
(D) It is a context-sensitive language regular?
[GATE 1991 : IIT Madras] 4. A is a DFA and N is an NFA. Is
Q.29 Which of the following statements is L( A)  L( N ) ?
false? (A) 3 only (B) 3 and 4 only
(A) The halting problem for Turing (C) 1, 2 and 3 only (D) 2 and 3 only
machines is un-decidable
[GATE 2013 : IIT Bombay]
(B) Determining whether a context
Q.33 Which one of the following problems
free grammar is un-decidable
is un-decidable?
(C) Given two arbitrary context free
(A) Deciding if a given context-free
grammars G1 and G2 it is grammar is ambiguous.
undecidable whether (B) Deciding if a given string is
L(G1 )  L(G2 ) generated by a given context-free
grammar.
(D) Given two regular grammars G1
(C) Deciding if the language generated
and G2 , it is un-decidable by a given context-free grammar
whether L(G1 )  L(G2 ) is empty.
[GATE 1996 : IISc Bangalore] (D) Deciding if the language generated
by a given context-free grammar
Q.30 Which of the following are decidable?
is finite.
1. Whether the intersection of two
[GATE 2014 : IIT Kharagpur]
regular language is infinite
Q.34 Which of the following decision
2. Whether a given context-free
problems are undecidable?
language is regular
3. Whether two push-down I. Given NFAs N1 and N2 , is
automata accept the same L( N1 )  L( N2 )   ?
language
II. Given a CFG G  ( N , , P, S ) and
4. Whether a given grammar is
a string x   *, does x  L (G ) ?
context-free
(A) 1 and 2 (B) 1 and 4 III. Given CFGs G1 and G2 is
(C) 2 and 3 (D) 2 and 4 L(G1 )  L(G2 ) ?
[GATE 2008 : IISc Bangalore]
IV. Given a TM M, is L ( M )   ?
Q.31 Which of the following problems are
(A) I and IV only
decidable?
(B) II and III only
1. Does a given program ever
produce an output? (C) III and IV only
(D) II and IV only
2. If L is a context-free language,
[GATE 2016 : IISc Bangalore]
then, is L also context-free?
Q.35 Define languages L0 and L1 as follows
3. If L is a regular language, then, is
L also regular? L0 ={< M,w,0> M halts on w}

Theory of Computation 31
L1  { M, w,1  M does not halts on (B) If A m B and A is undecidable
w} then B is un-decidable.
Here <M, w, i > is a triplet, whose (C) If A m B and B is recursively
first component, M is an encoding of enumerable then A is recursively
a Turing machine, second component, enumerable.
w, is a string, and third component, i,
(D) If A m B and B is not recursively
is a bit.
enumerable then A is not
Let L = L0  L1 . Which of the
recursively enumerable.
following is true?
[GATE 2004 : IIT Delhi]
(A) L is recursively enumerable, but
Q.38 Let X be a recursive language and Y be
L is not a recursively enumerable but not
(B) L is recursively enumerable, but recursive language. Let W and Z be
L is not two languages such that Y reduce to
(C) Both L and L are recursive W and Z reduces to X (reduction
(D) Neither L nor L is recursively means the standard many-one
enumerable reduction). Which one of the following
[GATE 2003 : IIT Madras] statements is TRUE?
(A) W can be recursively enumerable
Q.36 L1 is recursively enumerable language
and Z is recursive.
over  . An algorithm A effectively (B) W can be recursive and Z is
enumerates its words as w1 ,w 2 , w 3 .... recursively enumerable.
Define another language L 2 over (C) W is not recursively enumerable
and Z is recursive.
# as (D) W is not recursively enumerable
wi # w j : wi , w j  L1,i  j . Here # is a and Z is not recursive.
new symbol. Consider the following [GATE 2016 : IISc Bangalore]
assertions : Q.39 Let A and B be finite alphabets and let
# be a symbol outside both A and B.
S1: L1 is recursive implies L 2 is
Let f be a total function from A* to B*
recursive . We say f is computable if there exists
S2 : L 2 is recursive implies L1 is a Turing machine M which given an
recursive input x in A*, always halts with f(x) on
Which of the following statements is its tape. Let Lf denote the languages
TRUE?
{x#f(x) x  A*} .
(A) Both S1 and S2 are true
Which of the following statement is
(B) S1 is true but S2 is not necessarily TRUE:
true (A) f is computable if and only if Lf is
(C) S2 is true but S1 is not necessarily recursive
true (B) f is computable if and only if Lf is
(D) Neither is necessarily true recursively enumerable
[GATE 2004 : IIT Delhi] (C) If f is computable then if Lf is
Q.37 Let A m B denotes that language A is recursive, but not conversely
mapping reducible (also known as (D) If f is computable then if Lf is
many-to-one reducible) to language B.
recursive, but not conversely
Which one of the following is FALSE?
[GATE 2017 : IIT Roorkee]
(A) If A m B and B is recursive then A
is recursive.

32 Theory of Computation
Q.40 Consider the following sets: (B) P3 is un-decidable if P3 is
S1. Set of all recursively enumerable
reducible to P2
languages over the alphabet {0, 1}
S2. Set of all synthetically valid C (C) P3 is un-decidable if P2 is
programs reducible to P3
S3. Set of all languages over the
alphabet {0, 1} (D) P3 is decidable if P3 is reducible
S4. Set of all non – regular languages to P2 ' s complement
over the alphabet {0, 1} [GATE 2005 : IIT Bombay]
Which of the above sets are Q.43 Let  be a finite non-empty alphabet
uncountable?
and let 2* be the power set of  * .
(A) S1 and S2 (B) S3 and S4
Which one of the following is TRUE?
(C) S2 and S3 (D) S1 and S4
[GATE 2019 : IIT Madras] (A) Both 2* and  * are countable
Q.41 Consider the following problem X . (B) 2* is countable and * is
“Given a Turing machine M over the uncountable
input alphabet  , any state q of M (C) 2* in uncountable and  * is
and a word w  *, does the countable
computation of M on w visit the (D) Both 2* and  * are uncountable
state q " [GATE 2014 : IIT Kharagpur]
Which of the following statements Q.44 Consider two decision problems
about X is correct? Q1 , Q 2 such that Q1 reduces in
(A) X is decidable
polynomial time to 3-SAT and 3-SAT
(B) X is un-decidable but partially
reduces in polynomial time to Q2 .
decidable
Then which one of the following is
(C) X is un-decidable and not even
consistent with the above statement?
partially decidable
(D) X is not a decision problem
(A) Q1 is in NP, Q2 is NP hard.
[GATE 2001 : IIT Kanpur]
Q.42 Consider three decision problems (B) Q2 is in NP, Q1 is NP hard.
P1 , P2 and P3 . It is known that P1 is (C) Both Q1 and Q2 in NP.
decidable and P2 is un-decidable. (D) Both Q1 and Q2 are NP hard.
Which of the following is TRUE?
[GATE 2015 : IIT Kanpur]
(A) P3 is decidable if P1 is reducible to
P3

Q.1 Which of the following statements is (D) The families of recursively


false? enumerable and recursive
(A) Every context-sensitive language is languages are closed under
recursive reversal.
(B) The set of all languages that are Q.2 Which of the following problems is
not recursively enumerable is undecidable?
countable. (A) To determine if two finite
(C) The family of recursively automata are equivalent
enumerable languages is closed (B) To determine if two finite
under union. automata are equivalent

Theory of Computation 33
(C) Finiteness problem for finite (B) Checking whether a given context
automata free language is regular is
(D) Ambiguity problem for context free decidable.
grammar (C) Checking whether a given context
Q.3 Let S be an NP-complete problem. Q free language is empty is decidable.
and R are other two problems not (D) Both A and B
known to be NP. Q is polynomial time Q.7 Given the following two statements:
reducible to S and S is polynomial time S1:If L1 and L2 are recursively
reducible to R. Which of the following enumerable languages over ∑, then L1 ∪
statements is true? L 2 and L2 ∩ L2 are also recursively
(A) R is NP-complete enumerable. S2: The set of recursively
(B) R is NP-hard enumerable languages is countable.
(C) Q is NP-complete Which of the following is correct ?
(D) Q is NP-hard (A) S 1 is correct and S 2 is not correct
Q.4 Let L(R) be the language represented (B) S 1 is not correct and S 2 is correct
by regular expression R. Let L(G) be the (C) Both S 1 and S 1 are not correct.
language generated by a context free (D) Both S 1 and S 1 are correct.
grammar G. Let L(M) be the language Q.8 A problem whose language is recursive
accepted by a Turing machine M. Which is called?
of the following decision problems are (A) Unified problem
decidable? I. Whether L(G) is (B) Boolean function
deterministic context free (C) Recursive problem
language? II. Whether L(G1)∩L(G2) is a (D) Decidable
context free language, where G1 and G2
Q.9 Which of the following is FALSE with
are deterministic grammar? III. Given a
respect to possible outcomes of
context-free grammar G, is L(G)=Σ∗ for
executing a Turing Machine over a given
some alphabet Σ? IV. Given a Turing
input?
machine M and a string w, is w ∈ L(M)?
(A) it may halt and accept the input
(A) III and IV only
(B) it may halt by changing the input
(B) II and IV only
(C) it may halt and reject the input
(C) I and II only
(D) it may never halt
(D) None of the above
Q.10 Which of the following pairs have
Q.5 Which of the following statement is different expressive power?
false?
(A) Single-tape-turing machine and
(A) Checking the ambiguity of CFL is
multi-dimensional turing machine.
decidable.
(B) Multi-tape turing machine and
(B) Checking whether a given context
multi-dimensional turing machine.
free language is regular is
(C) Deterministic push down automata
decidable.
and non-deterministic pushdown
(C) Checking whether a given context automata.
free language is empty is decidable.
(D) Deterministic finite automata and
(D) Both A and B
Non-deterministic finite automata
Q.6 Which of the following statement is
Q.11 What is the highest type number that
false?
can be assigned to the following
(A) Checking the ambiguity of CFL is grammar?
decidable.
S → Aa
A → Ba

34 Theory of Computation
B → abc Q.14 Let L = {ap | p is a prime}. Then which
(A) Type 0 (B) Type 1 of the following is true?
(C) Type 2 (D) Type 3 (A) It is not accepted by a Turing
Q.12 If L and P are two recursively Machine
enumerable languages, then they are (B) It is regular but not context free
not closed under (C) It is context free but not regular
(A) Kleene Star L * of L (D) It is neither regular nor context
(B) Intersection L ∩ P free, but accepted by a Turing
(C) Union L ∪ P Machine
(D) Set Difference Q.15 A language L is called Turing-decidable
Q.13 Which of the following statements is (or just decidable), if there exists a
not correct? Turing Machine M such that on input x,
(A) Every recursive language is M accepts if x ∈ L, and M rejects
recursively enumerable. otherwise. L is called undecidable if it
(B) L = {0n1n 0n │n=1, 2 , 3, ....} is is not decidable. Which of following
recursively enumerable. option is false?
(C) Recursive languages are closed (A) The class of decidable languages is
under intersection. closed under complement.
(D) Recursive languages are not closed (B) The class of decidable languages is
under intersection. closed under union
(C) The class of decidable languages is
closed under intersection
(D) None of these

Classroom Practice Questions


1. B 2. C 3. D 4. D 5. A, C
6. C 7. B 8. B 9. A, C 10. D
11. A 12. B 13. D 14. B 15. D

16. D 17. D 18. B 19. B 20. D


21. D 22. C 23. D 24. B 25. D
26. B, D 27. B 28. C 29. D 30. B

31. D 32. D 33. A 34. C 35. D


36. A 37. B 38. C 39. A 40. B

41. B 42. C 43. C 44. A


Practice Questions
1. B 2. D 3. B 4. D 5. D

6. D 7. D 8. D 9. B 10. C
11. D 12. D 13. D 14. D 15. D



Theory of Computation 35
6 FSM with Output
Q.1 A finite state machine with the Q.2 The finite state machine described by
following state table has a single input the following state diagram with A as
X and a single output Z. starting state, where an arc label is x/y
Next state Z and x stands for 1-bit input and y
Present
stands for 2-bit output
state X= 1 X=0
A D,0 B,0
B B,1 C,1
C B,0 D,1
D B,1 C,0 (A) Outputs the sum of the present
and the previous bits of the input
If the initial state is unknown, then the
shortest input sequence to reach the (B) Outputs 01 whenever the input
final state C is sequence contains 11
(A) 01 (B) 10 (C) Outputs 00 whenever the input
sequence contains 10
(C) 101 (D) 110
(D) None of the above
[GATE 1995 : IIT Kanpur]
[GATE 2002 : IISc Bangalore]

Q.1 Given the following state table of an which will take the machine to the
FSM with two states A and B, one input state A  0, B  1 with Output = 1?
and one
(A) 3 (B) 4
output :
(C) 5 (D) 6
Prese Pres Q.2 The FSM (finite state machine)
Next Next
nt ent Inpu Outp
state state ut machine pictured in the figure above
state state t
A B
A B
0 0 0 0 0 1
0 1 0 1 0 0
1 0 0 0 1 0
1 1 0 1 0 0
0 0 1 0 1 0
(A) Complementsa given bit pattern
0 1 1 0 0 1
(B) Finds 2’s complement of a given
1 0 1 0 1 1
bit pattern
1 1 1 0 0 1
(C) Increments a given bit pattern by 1
If the initial state is A  0, B  0 , what is (D) Changes the sign bit
the minimum length of an input string

36 Theory of Computation
Classroom Practice Questions
1. B 2. A
Practice Questions
1. A 2. C



Theory of Computation 37

You might also like