Unacademy Workbook Toc
Unacademy Workbook Toc
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
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?
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 n1
[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 n1 (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.
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 xL, 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) kn (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)
1 0,1 0 0
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
SA
(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
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?
(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
14 Theory of Computation
3 Grammar, Language and it's Application
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
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]
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 EEE
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
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 ,
nm 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
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
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
*
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?
(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
26 Theory of Computation
5 TM and Un-Decidability
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
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
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