0% found this document useful (0 votes)
92 views

Deterministic Finite Automata: 1. (MCQ) (GATE-2021: 2M) 3. (NAT) (GATE-2021: 1M)

This document discusses the design of springs. Springs are designed to store mechanical energy when compressed or stretched from their resting length. The rate at which they store this energy, called the spring constant, depends on the material and shape of the spring. Common spring designs include compression springs, extension springs, and torsion springs. Compression springs get shorter when compressed while extension springs get longer when stretched. Torsion springs store energy through twisting.

Uploaded by

dzz9wt7x9k
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views

Deterministic Finite Automata: 1. (MCQ) (GATE-2021: 2M) 3. (NAT) (GATE-2021: 1M)

This document discusses the design of springs. Springs are designed to store mechanical energy when compressed or stretched from their resting length. The rate at which they store this energy, called the spring constant, depends on the material and shape of the spring. Common spring designs include compression springs, extension springs, and torsion springs. Compression springs get shorter when compressed while extension springs get longer when stretched. Torsion springs store energy through twisting.

Uploaded by

dzz9wt7x9k
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

Design of springs

CHAPTER

1
Deterministic Finite Automata 3. [NAT] [GATE-2021 : 1M]
1. [MCQ] [GATE-2021 : 2M] Consider the following deterministic finite
Consider the following language: automaton (DFA)
L = {w  {0,1} * | w ends with the substring 011}
Which one of the following deterministic finite
automata accepts L?

(a)
The number of strings of length 8 accepted by the
above automaton is ___.

4. [MCQ] [GATE-2013 : 2M]


(b) Consider the DFA A given below.
Which of the following are FALSE?
1. Complement of L(A) is context-free.
(c) 2. L(A) = L((11*0 + 0) (0 + 1)*0*1*)
3. For the language accepted by A, A is the
minimal DFA
4. A accepts all strings over {0, 1} of length at least 2.

(d)

2. [MCQ] [GATE-2021 : 1M]


Let L  {0, 1}* be an arbitrary regular language
accepted by a minimal DFA with k states. Which
one of the following languages must necessarily be
accepted by a minimal DFA with k states?
(a) 1 and 3 only (b) 2 and 4 only
(a) L – {01} (b) L  {01}
(c) 2 and 3 only (d) 3 and 4 only
(c) {0, 1} * – L (d) L . L

8.1
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

5. [MCQ] [GATE-2012 : 2M] 6. [MCQ] [GATE-2011 : 1M]


Consider the set of strings on {0,1} in which, every A deterministic finite automaton (DFA) D with
substring of 3 symbols has at most two zeros. For alphabet  = {a, b} is given below:
example, 001110 and 011001 are in the language,
but 100010 is not. All strings of length less than 3 a,b
are also in the language. A partially completed DFA p b q b r
that accepts this language is shown below. The
missing arcs in the DFA are a a
a,b a,b
s t

Which of the following finite state machines is a


valid minimal DFA which accepts the same
language as D?
a,b

p b q b
(a) r
a a
s
(a)
00 01 10 11 q
00 1 0
a,b
01 1 a,b
10 0
s
11 0 (b) b a,b
(b) p a,b q r
00 01 10 11 q a
00 0 1
01 1 a,b
10 0 a,b
11 0 (c) a,b b
p q r
(c)
00 01 10 11 q
00 1 0
01 1
b
10 0
11 0 p b q
(d)
00 01 10 11 q a a
00 1 0 (d)
s
01 1
10 0 a,b
11 0

8.2
GATE Wallah CS & IT Topic wise PYQs
Finite Automata and Transducer

7. [MCQ] [GATE-2009 : 2M] 10. [MCQ] [GATE-2012 : 2M]


What is the complement of the language accepted by
the NFA shown below?
Assume Σ = {a} and ε is the empty string.

The above DFA accepts the set of all strings over


{0,1} that
(a) Begin either with 0 or 1. (a) ϕ (b) {ε}
(b) End with 0. (c) a* (d) {a, ε}
(c) End with 00. 11. [MCQ] [GATE-2008 : 2M]
(d) Contain the substring 00. Given below are two finite state automata
(→ indicates the start and F indicates a final state)

Non-Deterministic Finite Automata


8. [MCQ] [GATE-2017 : 2M]
Let δ denote the transition function and ̂ denote
the extended transition function of the -NFA Which of the following represents the product
whose transition table is given below: automaton Z × Y ?

  a b (a) (b)

→q0 {q2} {q1} {q0}

q1 {q2} {q2} {q3}


q2 {q0}  
(c) (d)
q3   {q2}

The ̂ (q2, aba) is


(a) Φ (b) {q0, q1, q3}
(c) {q0, q1, q2} (d) {q0, q2, q3}
12. [MCQ] [GATE-2008 : 2M]
Consider the following two finite automata. M1
9. [MCQ] [GATE-2014 : 1M]
accepts L1 and M2 accepts L2.
Consider the finite automaton in the following
figure.

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}

8.3
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

Which one of the following is TRUE? 16. [NAT] [GATE-2019 : 2M]


(a) L1 = L2 (b) L1 ∩ L2 =  Let  be the set of all bijections from {1, …, 5} to
{1, …, 5}, where id denotes the identity function,
(c) L1 LC2 =  (d) L1  L2   i.e. id(j) = j, j. Let  denote composition on
functions. For a string x = x1x2 … xn  n, n  0, let
(x) = x1 x2 …  xn.
Finite Automata Interconversion Consider the language L = {x  * | (x) = id}. The
13. [MCQ] [GATE-2008 : 2M] minimum number of states in any DFA accepting L
If the final states and non-final states in the DFA is ______.
below are interchanged, then which of the following
languages over the alphabet {a, b} will be accepted 17. [MCQ] [GATE-2018 : 1M]
by the new DFA? Let N be an NFA with n states. Let k be the number
of states of a minimal DFA which is equivalent to N.
Which one of the following is necessarily true?
(a) k ≥ 2n (b) k ≥ n
(c) k ≤ n2 (d) k ≤ 2n

(a) Set of all strings that do not end with ab 18. [NAT] [GATE-2017 : 1M]
(b) Set of all strings that begin with either an a or ab The minimum possible number of states of a
(c) Set of all strings that do not contain the substring deterministic finite automaton that accepts the
ab. regular language L = {w1 a w2| w1, w2 ∈{a, b}*,
(d) The set described by the regular expression |w1|=2,|w2| ≥ 3} is___________.
b*aa*(ba)*b*
19. [NAT] [GATE-2015 : 2M]
Minimization
14. [NAT] [GATE-2023 : 1M]
Consider the language L over the alphabet {0, 1},
given below:
L = {w ∈ {0, 1}* | w does not contain three or more
consecutive 1’s}. Consider the DFAs M and N given above. The number
The minimum number of states in a Deterministic of states in a minimal DFA that accepts the language
Finite-state Automaton (DFA) for L is _____. L(M)  L(N) is _______.

20. [MCQ] [GATE-2011 : 2M]


15. [NAT] [GATE-2020 : 2M]
Definition of a language L with alphabet {a} is given
Consider the following language: as following:
L = {x {a, b} *| number of a's in x is divisible by 2 L = {ank | k > 0, and n is a positive integer constant}.
but not divisible by 3} What is the minimum number of states needed in a
The minimum number of states in a DFA that accepts DFA to recognize L?
(a) k + 1 (b) n + 1
L is ______. n +1
(c) 2 (d) 2k + 1

8.4
GATE Wallah CS & IT Topic wise PYQs
Finite Automata and Transducer

21. [MCQ] [GATE-2010 : 2M] Assume the initial state of the Mealy machine is 0.
Let w be any string of length n in {0,1}*. Let L be What are the Boolean expressions corresponding to
the set of all substrings of w. What is the minimum t and y in terms of s and b?
number of states in a non-deterministic finite (a) t = s + b
automaton that accepts L? y = sb
(a) n – 1 (b) n (b) t = b
(c) n + 1 (d) 2n – 1 y = sb
(c) t = b
22. [MCQ] [GATE-2008: 1M]
y = sb
Let N be an NFA with n states and let M be the
(d) t = s + b
minimized DFA with m states recognizing the same
language. Which of the following is y = sb
NECESSARILY true?
(a) m ≤ 2n 24. [MCQ] [GATE-2009 : 2M]
(b) n ≤ m Given the following state table of an FSM with two
(c) M has one accept state states A and B, one input and one output:
(d) m = 2n
Present Present Input Next Next Output
State A State B State State
Mealy Machine A B
23. [MCQ] [GATE-2021 : 2M] 0 0 0 0 0 1
Suppose we want to design a synchronous circuit
0 1 0 1 0 0
that processes a string of 0’s and 1’s. Given a string,
it produces another string by replacing the first 1 in 1 0 0 0 1 0
any subsequence of consecutive 1’s by a 0. Consider
1 1 0 1 0 0
the following example.
Input sequence: 00100011000011100 0 0 1 0 1 0
Output sequence: 00000001000001100 0 1 1 0 0 1
A mealy Machine is a state machine where both the 1 0 1 0 1 1
next state and the output are functions of the present
state and the current input. 1 1 1 0 0 1

The above-mentioned circuit can be designed as a If the initial state is A = 0, B = 0, what is the
two-state Mealy machine. The states in the Mealy minimum length of an input string which will take
machine can be represented using Boolean values 0 the machine to the state A = 0, B = 1 with output
and 1. We denote the current state, the next state, the = 1?
next incoming bit, and the output bit of the Mealy (a) 3 (b) 4
machine by the variables s, t, b and y respectively. (c) 5 (d) 6

❑❑❑

8.5
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

1. (d) 2. (c) 3. (256 to 256) 4. (d)


5. (d) 6. (a) 7. (c) 8. (c)
9. (a) 10. (b) 11. (Marks to All) 12. (a, c)
13. (a) 14. (4 to 4) 15. (6 to 6) 16. (120 to 120)
17. (d) 18. (8 to 8) 19. (1 to 1) 20. (b)
21. (c) 22. (a) 23. (b) 24. (a)

1. (d) 3. (256 to 256)

DFA for ending with 011: Every symbol is having two choices

0101010101010101
2 2 2 2 2 2 2 2
Total strings with length 8 = 28
Total strings with length 8 = 256

Hence, option (d) is correct.

4. (d)
1. L(A) = Regular
2. (c)
L = *– L Complement of L(A) = Regular = Regular
= {0, 1}* – L Every Regular language is CFL
If L is a DFA with K states than in L DFA also
2. L(A) = 11*0(0 + 1)* + 0(0 + 1)*
having K states because number of states in L and
L are same. = (11*0 + 0) (0 + 1)*

= (1+ 0 + 0) ( 0 + 1)*

= (1+ + ) 0 (0 + 1)*

= 1*0 (0 + 1)*

8.6
GATE Wallah CS & IT Topic wise PYQs
Finite Automata and Transducer

3. Minimal DFA for [1*0 (0 + 1)*]: (iii) {p}, {q}, {r}, {s, t}
Number of states = 4.
Here s and t are equivalent.
a,b
Number of states in minimal DFA = 2
p b q b
r
4. Given DFA accepts all strings containing 0 as
substring. a a
s

a,b

5. (d)
From state 00 to read input 0  q(dead state)
From state 00 to read input 1  01
From state 01 to read input 1  11
7. (c)
Minimal accepted string = 00
It will accept all the strings end with 00.

8. (c)
-NFA:

Hence, option (d) is correct.

Transition with (q2, aba):

6. (a)
Partition algorithm:
(i) {p, q, r} {s, t}
Non-final Final
(ii) {p, q}, {r}, {s, t}

8.7
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

11. (Marks to All)


ˆ ( q2 ,aba ) = {q1,q 2 ,q0}
Z × Y:
Hence, option (c) is correct. → Z1Y1 Z2Y1 Z2Y2
Z1Y2 Z2Y2 Z2Y1
Z2Y1 Z1Y1 Z1Y2
Z2Y2 Z1Y2 Z1Y1

a b
→P S R
Q R S
9. (a) S P Q
Reachable states for the input string 0011: R Q P
We don’t have correct option

ˆ ( q0 ,0011) = {q0 , q1, q 2 }


12. (a, c)
Hence, option (a) is correct. L1 (M1) is DFA and it accepts (0 + 1)* 11 (0 + 1)*
L2 (M2) is NFA and it accepts (0 + 1)* 11 (0 + 1)*
Both L1 and L2 are equal and 𝐿1 ∩ 𝐿𝐶2 = 𝜙is also
correct.

10. (b)

13. (a)
Complement of given machine:

 L = a+

L = * −L

= a* – a+

= {} It will accept set of all strings that do not end with
ab.

8.8
GATE Wallah CS & IT Topic wise PYQs
Finite Automata and Transducer

14. (4 to 4) 16. (120 to 120)


DFA for L: If  is set of all bijections from {1, 2} to {1, 2}
Number of bijective functions = 2! = 2
Here, Language L = {, f1, f1f2, f2f2 ….}
Number of states =2

DFA for L

If set has 2 elements, then 2! bijective functions and


hence 2! States.
Each bijective function requires one state to
represent as result of some composition.
Number of states will be same in both L and L .
If set has 5 elements, then number of bijective
Number of states = 4
functions = 5! and number of states = 5!
Number of states = 5 × 4 × 3 × 2 × 1 = 120

15. (6 to 6)
Divisible by 2 strings = , aa, aaaa, aaaaaa, ….. 17. (d)
Divisible by 3 strings = , aaa, aaaaaa, aaaaaaaaa, If NFA (N) having ‘n’ states and DFA having ‘k’
….. states.
Divisible by 2 but not 3 strings = a2, a4, a8, a10, a12, Then, relation between k and n is using subset
….. construction algorithm is:

DFA design for number of a’s divisible by k  2n


2 but not 3:

18. (8 to 8)
L = {w1aw2 | w1, w2  {a, b}*, |w1| = 2, |w2| > 3}
= (a + b)2 a (a + b)3 (a + b)*
Number of states = 6
DFA for L:

8.9
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

Number of states in DFA for L = 8.

4 states are needed.


For L = {ank | k > 0, n is constant}, n + 1 states are
needed.
19. (1 to 1)
M accepts all strings ending in a.
L(M) = (a + b)* a
N accepts all strings ending in b.
L (N) = (a + b)* b
L(M)  L(N) =  21. (c)
w = abb(n = 3)  L = {, a, b ab, bb, abb}
To represent empty language, only one state present
DFA for abb:
in minimal DFA.
DFA:

Accept w = abb
DFA for L:
To design DFA for  minimum 1 state is needed.

For 3 length 4 states are needed. So, for n length n +


20. (b) 1 states are needed.
L = {ank | k > 0, and n is a positive integer
constant}.
• If n = 1  L = {ak | k > 0}
L = a+
FA:
22. (a)
NFA(N)  n states
2 states are needed. Min DFA(M)  m States
• If n = 2  L = {a | k > 0}
2k
Relation between m & n:
L = (aa)+ DFA having  2n states
m  2n

3 states are needed.


• If n = 3  L = {a3k | k > 0}
L = (aaa)+

8.10
GATE Wallah CS & IT Topic wise PYQs
Finite Automata and Transducer

23. (b) 24. (a)


Input = 001011110 A = 0, B = 1 and output = 1
Output = 000001110
Mealy Machine:

Transition Table:
s b
0 1
0 0, 0 1, 0
t, y t, y
1 0, 0 1, 1
t, y t, y Input = 101
From state 00, by reading 3 length minimum input
t=b
it takes to 01.
y = sb
Hence, option (b) is correct.

❑❑❑

8.11
GATE Wallah CS & IT Topic wise PYQs
Design of springs

CHAPTER

2
Construction of Regular Expression 4. [MCQ] [GATE-2013 : 1M]
1. [MSQ] [GATE-2021 : 2M] Consider the languages L1 = ϕ and L2 = {a}. Which
Which of the following regular expressions one of the following represents L1L2*  L1* ?
represent(s) the set of all binary numbers that are (a) {} (b) ϕ
divisible by three? Assume that the string  is (c) a* (d) {, a}
divisible by three.
(a) (0 + 1(01* 0)* 1)* 5. [MCQ] [GATE-2012 : 1M]
(b) (0 + 11 + 10(1 + 00)* 01)* Given the language L = {ab, aa, baa}, which of the
following strings are in L*?
(c) (0*(1(01* 0)* 1)*)*
1. abaabaaabaa
(d) (0 + 11 + 11(1 + 00)* 00)* 2. aaaabaaaa
3. baaaaabaaaab
2. [MCQ] [GATE-2020 : 1M] 4. baaaaabaa
Which one of the following regular expressions (a) 1, 2 and 3 (b) 2, 3 and 4
represents the set of all binary strings with an odd (c) 1, 2 and 4 (d) 1, 3 and 4
number of 1 's?
(a) (0* 10* 10*) * 0* 1 6. [MCQ] [GATE-2010 : 2M]
(b) 10*(0* 10* 10*)* Let L = {w (0 + 1)* | w has even number of 1s},
(c) ((0 + 1)* 1(0 + 1)* 1)* 10* i.e., L is the set of all bit strings with even number
of 1s. Which one of the regular expressions below
(d) (0* 10* 10*)* 10*
represents L ?
(a) (0* 10* 1)* (b) 0*(10* 10*)*
3. [MCQ] [GATE-2016 : 1M]
(c) 0*(10* 1)* 0* (d) 0* 1(10* 1)* 10*
Which one of the following regular expressions
represents the language: the set of all binary strings
7. [MCQ] [GATE-2009 : 2M]
having two consecutive 0’s and two consecutive
Which one of the following languages over the
1’s?
alphabet {0,1} is described by the regular
(a) (0 + 1) * 0011(0 + 1)* + (0 + 1)* 1100(0 + 1) * expression: (0 + 1)* 0(0 + 1)* 0(0 + 1)* ?
(b) (0 + 1) *(00(0 + 1) * 11 + 11(0 + 1) * 00) (a) The set of all strings containing the substring 00
(0 + 1) * (b) The set of all strings containing at most two 0’s
(c) (0 + 1) * 00(0 + 1) * + (0 + 1) * 11(0 + 1) * (c) The set of all strings containing at least two 0's
(d) 00(0 + 1) * 11+11(0 + 1) * 00 (d) The set of all strings that begin and end with
either 0 or 1

8.12
GATE Wallah CS & IT Topic wise PYQs
Regular Expression

8. [MCQ] [GATE-2008 : 1M]


Which of the following regular expressions
describes the language over {0, 1} consisting of
strings that contain exactly two 1’s?
(a) (0 + 1) * 11(0+1) *
(b) 0 * 110*
(c) 0 * 10* 10* (a) a b* b a b* + b a* a b a*
(d) (0 + 1) * 1(0 + 1) * 1 (0 + 1) * (b) (a b* b)* a b* + (b a* a)* b a*
(c) (a b* b + b a* a)*(a* + b*)
Interconversion Regular Expression to (d) (b a*a + a b* b)*(a b* + b a*)
Finite Automata
9. [MCQ] [GATE-2023 : 1M] 11. [NAT] [GATE-2017 : 1M]
Consider the Deterministic Finite-state Automaton Consider the language L given by the regular
(DFA) A shown below. The DFA runs on the expression (a + b)* b(a + b) over the alphabet {a,
alphabet {0, 1}, and has the set of states {s, p, q, r}, b}. The smallest number of states needed in a
with s being the start state and p being the only final deterministic finite-state automaton (DFA)
state. accepting L is________.

0
1 12. [NAT] [GATE-2016 : 1M]
The number of states in the minimum sized DFA that
1 p
s q accepts the language defined by the regular
expression (0 + 1)*(0 + 1)(0 + 1) * is______.
1
13. [MCQ] [GATE-2015 : 1M]
0 0
r Let L be the language represented by the regular
expression Σ* 0011 Σ* where Σ = {0, 1}.
What is the minimum number of states in DFA that
0, 1
recognizes L (complement of L)?
Which one of the following regular expressions (a) 4 (b) 5
correctly describes the language accepted by A? (c) 6 (d) 8
(a) 1(0*11)*
14. [NAT] [GATE-2015 : 2M]
(b) 0(0 + 1)*
The number of states in the minimal deterministic
(c) 1(0 + 11)* finite automaton corresponding to the regular
(d) 1(110*)* expression (0 + 1)*(10) is ______.

10. [MCQ] [GATE-2022 : 1M] 15. [NAT] [GATE-2014 : 1M]


Which one of the following regular expressions The length of the shortest string NOT in the language
correctly represents the language of the finite (over Σ = {a, b} ) of the following regular expression
automaton given below? is ________.
a* b* (ba)* a*
8.13
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

16. [MCQ] [GATE-2014 : 2M] R


Which of the regular expressions given below
represent the following DFA?

S
I. 0* 1(1 + 00* 1)*
II. 0* 1* 1 + 11* 0* 1
III. (0 + 1)* 1
(a) I and II only (b) I and III only
(c) II and III only (d) I, II and III

17. [MCQ] [GATE-2008 : 2M]


Match List - I with List - II and select the correct List - II
answer using the codes given below the lists:
1. ε + 0(01*1 + 00)*01*
List – I
2. ε + 0(10*1 + 00)*0
P 3. ε + 0(10*1 + 10)*1
4. ε + 0(10*1 + 10)*10*

P Q R S
(a) 2 1 3 4
(b) 1 3 2 4
(c) 1 2 3 4
Q (d) 3 2 1 4

❑❑❑

8.14
GATE Wallah CS & IT Topic wise PYQs
Regular Expression

1. (a, b, c) 2. (Marks to All) 3. (b) 4. (a)


5. (c) 6. (b) 7. (c) 8. (c)
9. (c) 10. (d) 11. (4 to 4) 12. (2 to 2)
13. (b) 14. (3 to 3) 15. (3 to 3) 16. (b)
17. (c)

1. (a, b, c) Delete q2:


0 1
=
→*q0 q0 q1
q1 q2 q0
q2 q1 q2 Regular expression = (0 + 11 + 10 (1 + 00)*01)*

Approach 1: First delete q2 then q1.


Delete q2: 2. (Marks to All)
(a) (0* 10* 10*) * 0* 1
This regular expression always ending with 1.
It can’t generate 10
Delete q1: (b) 10*(0* 10* 10*)*
This regular expression always starting with 1.
= It can’t generate 01
(c) ((0 + 1)* 1(0 + 1)* 1)* 10*
It will generate even number of 1 also.
R = (0 + 1 (01 * 0) * 1)* = (0*(1(01* 0)* 1)*)*
(d) (0* 10* 10*)* 10*
Compare with (a + b)* = (a*b*)*
This regular expression can not generate 01
Approach 2: First delete q1 then q2. string.
Delete q1 :

8.15
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

3. (b) There are many ways two represent the regular


Regular expression that generates all strings having expression for even number of 1’s.
00 and 11. Matched with option (b).
= X 00 X 11 X + X 11 X 00 X

Here, Assume X = (0 + 1)*


= X [00 X 11 + 11X00] X
= (0 + 1)*[00(0 + 1)*11 + 11(0 + 1)*00](0 + 1)* 7. (c)
It is matched with option (b). a. X00X is containing 00.
b. 1* (0 + ) 1* (0 + ) 1* is containing atmost
two 0’s.
c. X0X0X is containing at least two 0’s.
d. (0 + 1)+ is begin and end with either 0 or 1.
4. (a)
Hence, option (c) is correct.
L1 = 
L2 = {a}
L1L*2 L*1 = ?
= .a*  * =   {} = {}
Note: * = {} 8. (c)
R.E that contain exactly two 1’s = 0*10*10*
Hence, option (c) is correct.

5. (c)
L = ab + aa + baa
L* = (ab + aa + baa)* 9. (c)

1. ab aa baa ab aa  L5 In given machine, r is dead state. After deleting state


q, the resultant transition graph is:
2. aa aa baa aa  L4
3. baa aa ab aa aa b  L*
4. baa aa ab aa  L4

Above transition graph represents R = 1 (0 + 11) *

6. (b)
Even number of 1’s = 0* (0*1 0* 10*)0*
= (0* 1 0* 1)* 0* = 0*(10* 10*)*

8.16
GATE Wallah CS & IT Topic wise PYQs
Regular Expression

10. (d) Here number of states are two for L = (0 + 1)+

13. (b)
L = * 0011*
L = (0 + 1)* 0011(0 + 1)*
DFA for L:

Expression = (b a*a + a b* b)*(a b* + b a*)

DFA for L :

11. (4 to 4)
DFA:

Number of states are always same in both L and L.

14. (3 to 3)
Minimal string for regular expression = 10
k 2
2 = 2 = 4 where k is the position of the symbol. DFA Design for (0 + 1)*(10):

12. (2 to 2)
(0 + 1)* (0 + 1) (0 + 1)* = (0 + 1)+ Number of states = 3

8.17
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

15. (3 to 3) 17. (c)


a* b* (ba)* a* P
It will produce all 0 length, 1 length and 2 length
string. But it will produce all 3 length string.
 Possible
a Possible
b Possible
aa Possible Regular expression = ε + 0(01*1 + 00)*01*
ab Possible
Q
ba Possible
bb Possible
bab Not Possible
The shortest string, which is NOT present in the
language = bab (3 length).

Regular expression = ε + 0(10*1 + 00)*0


R

16. (b)
I. 0*1(1 + 00*1)*
0*1 (( + 00*)1)*
0*1 (0*1)* Regular expression = ε + 0(10*1 + 10)*1
+
(0*1) S
II. 0* 1* 1 + 11* 0* 1 it will not generate 0101
string.
III. (0 + 1)* 1 is same as (0*1)+
Hence, I and III regular expressions are correct
with respective DFA.

Regular expression = ε + 0(10*1 + 10)*10*


Hence, opiton (c) is correct.

❑❑❑

8.18
GATE Wallah CS & IT Topic wise PYQs
Design of springs

CHAPTER

3
Regular Grammar and Pumping Lemma Consider the language L1 (over alphabet 0) accepted
1. [MCQ] [GATE-2023 : 1M] by the following automaton.
The order of L1 is _____________.
Consider the context-free grammar G below
S → aSb | X 4. [MCQ] [GATE-2016 : 2M]
X → aX | Xb| a | b Language L1 is defined by the grammar:
Where S and X are non-terminals, and a and b are S1 → aS1b | 
terminal symbols. The starting non-terminal is S. Language L2 is defined by the grammar:
Which one of the following statements is S2 → abS2 | 
CORRECT? Consider the following statements:
P: L1 is regular
(a) The language generated by G is (a + b) *
Q: L2 is regular
(b) The language generated by G is a*(a + b)b*
Which of the following is TRUE?
(c) The language generated by G is a*b*(a + b) (a) Both P and Q are true.
(d) The language generated by G is not a regualar (b) P is true and Q is false.
language. (c) P is false and Q is true.
2. [MCQ] [GATE-2019 : 1M] (d) Both P and Q are false.
For Σ={a, b}, let us consider the regular language
L = {x | x = a2 + 3k or x = b10 +12k, k ≥ 0}. 5. [MCQ] [GATE-2016 : 1M]
Which one of the following can be a pumping length (the
Which of the following languages is generated by the
constant guaranteed by the pumping lemma) for L?
given grammar?
(a) 3 (b) 5
S → aS | bS |
(c) 9 (d) 24
3. [NAT] [GATE-2018 : 2M] (a) {an bm| n, m ≥ 0}
Given a language L, define Li as follows: (b) {w {a, b}*| w has equal number of a's and
b’s}
L0 = {}
(c) {an| n ≥ 0}  {bn| n ≥ 0}  {an bn| n ≥ 0}
L1 = Li – 1. L for all i > 0
(d) {a, b}*
The order of a language L is defined as the smallest
k such that Lk = Lk + 1.
6. [MCQ] [GATE-2015 : 2M]
Consider alphabet Σ = {0,1}, the null/empty string λ
and the sets of strings X0, X1, and X2 generated by
the corresponding non-terminals of a regular
grammar. X0, X1 and X2 are related as follows:
X0 = 1 X1

8.19
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

X1 = 0 X1 + 1 X2 10. [MCQ] [GATE-2014 : 1M]


X2 = 0 X1 + {λ} If L1 = {a | n ≥ 0} and L2 = {bn | n ≥ 0}, consider
n

Which one of the following choices precisely I. L1 . L2 is a regular language


represents the strings in X0? II. L1 . L2 = {an bn | n ≥ 0}
(a) 10(0* + (10)*) 1 Which one of the following is CORRECT?
(b) 10(0* + (10)*)* 1 (a) Only I (b) Only II
(c) 1(0 + 10)* 1 (c) Both I and II (d) Neither I nor II
(d) 10(0 + 10)* 1 + 110(0 +10)* 1 11. [MCQ] [GATE-2008 : 2M]
Which of the following are regular sets?
Regular Language Identification I. {anb2m | n  0, m  0}
7. [MCQ] [GATE-2019 : 1M]
II. {anbm | n = 2m}
If L is a regular language over Σ = {a, b}, which one
III. {anbm | n  m}
of the following languages is NOT regular?
IV. {xcy | x, y  {a, b}*}
(a) L. LR = {x y | x  L, yR L}
(a) I and IV only (b) I and III only
(b) {w wR | w  L}
(c) IV only (d) IV only
(c) Prefix (L) = {x  * | ∃y* such that
Closure Properties of Regular Language
xyL}
12. [MCQ] [GATE-2020 : 1M]
(d) Suffix (L) ={y  * | ∃x* such that xyL}
Consider the following statements:
8. [MCQ] [GATE-2015 : 2M] I. If L1  L2 is regular, then both L1 and L2 must
Which of the following languages is/are regular? be regular.
L1: {w x wR | w, x {a, b}* and |w|,|x| > 0}, wR is II. The class of regular languages is closed under
the reverse of string w. infinite union.
L2: {an bm | m ≠ n and m, n ≥ 0} Which of the above statements is/are TRUE?
L3: {ap bq cr | p, q, r ≥ 0} (a) Both I and II (b) II only
(a) L1 and L3 only (b) L2 only (c) I only (d) Neither I not II
(c) L2 and L3 only (d) L3 only 13. [MCQ] [GATE-2016 : 2M]
9. [MCQ] [GATE-2014 : 2M] Consider the following two statements:
Let L1 = {w  {0, 1}* | w has at least as many I. If all states of an NFA are accepting states then
occurrences of (110)'s as (011)'s} . Let L2 = {w {0, the language accepted by the NFA is *.
1}*| w has at least as many occurrences of (000)'s as II. There exists a regular language A such that for
(111)'s}. Which one of the following is TRUE? all languages B, A  B is regular.
(a) L1 is regular but not L2 Which one of the following is CORRECT?
(b) L2 is regular but not L1 (a) Only I is true
(c) Both L1 and L2 are regular (b) Only II is true
(d) Neither L1 nor L2 are regular (c) Both I and II are true
(d) Both I and II are false

❑❑❑

8.20
GATE Wallah CS & IT Topic wise PYQs
Regular Language and Grammar

1. (b) 2. (d) 3. (2 to 2) 4. (c)


5. (d) 6. (c) 7. (b) 8. (a)
9. (a) 10. (a) 11. (a) 12 (d)
13. (b)

1. (b) 3. (2 to 2)
X = a*(a + b)b* L =  + 0 (00)* for given FA.
S = an bn = an a* (a + b) b* bn = a* (a + b) b*
L0 = {}

L1 = L0. L = .( + 0(00)*) = L

L2 = L1. L = L.L = [ + 0(00)*] [ + 0(00)*] = 0*

L3 = L2. L = 0*. ( + 0 (00)*) = 0*


So, O(L) = 2
2. (d)

4. (c)
• S1 → aS1b | 

L ={a2 + 3k }  {b10 + 12k} L1 = {an bn | n  0} is CFL


= aa (aaa)* + b10. (b12)* • S2 → abS2 | 
Number of states = 16 L2 = (ab)* is Regular
So, pumping length must be greater than 16. Hence, L1 is CFL and L2 is Regular.
Hence, option (d) is correct. So, option (c) is correct.

8.21
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

5. (d) 8. (a)
S → aS | bS |  L1: {wxwR |w, x  {a, b}+}
L = (a + b)* L1 = axa + bxb
= {a, b}* = a (a + b)+ a + b(a + b)+ b = Regular
Hence, option (d) is correct. L2: {an bm | n  m}= Not Regular
L3: a*b*c* = Regular
Hence, L1 and L3 are Regular.

6. (c)
X2 → 0X1 | 
X2 = 0X1 +  9. (a)
X1 → 0X1 | 1X2 L1 : n110 and n 011
X1 = 0X1 | 10X1 | 1 We can construct DFA for L1 with the help of cycle
X1 = (0 + 10)*1 to count number of occurrences of both patterns 110
X0 = 1X1 and 011. While counting one pattern, other pattern
X0 = 1(0 + 10)*1 will be either equal or one more or less compared to
other pattern. This can be remembered with the few
Hence, option (c) is correct.
states.
L2 : n000 and n111
We can not make DFA for L2. While counting 000,
there is no way to remember the count using DFA.
Hence, option (a) is correct.
7. (b)
(a) If L is Regular then L.LR is Regular.
(b) May/may not be Regular over Σ = {a, b}.
If L = a* then wwR = (aa)* is regular
If L = (a+b)* then wwR is not regular
10. (a)
(c) Prefix(Regular) is always Regular
(d) Suffix(Regular) is always Regular L1.L2 = a n1 bn2 n1 , n 2  0

Hence, option (b) is correct. = a*b* Regular language

8.22
GATE Wallah CS & IT Topic wise PYQs
Regular Language and Grammar

11. (a)
I. {anb2m | n  0, m  0}  a*(bb)*
II. {anbm | n = 2m}  CFL
III. {anbm | n  m}  CFL
IV. {xcy | x, y  {a, b}*} (a + b)* c (a + b)*
Hence, option (a) is correct. 13. (b)
I. FALSE
Consider the following NFA. Here all states are
accepting states, but language accepted by NFA
is not *.

12. (d)
I. If L1  L2 is Regular then, L1 and L2 may/may
not be regular.
an bn (DCFL)  a* b*(Regular) = Regular II. TRUE
A  B is Regular, when A is empty language.
an bn (DCFL)  (a + b)* (Regular) = Regular
  Any =  (Regular)
II. {}{ab}  {a2 b2} … = {anbn} is not
regular
Infinite union is not closed under regular
language.
Hence, option (d) is correct.

❑❑❑

8.23
GATE Wallah CS & IT Topic wise PYQs
Design of springs

CHAPTER

4
Pushdown Automata 2. [NAT] [GATE-2021 : 2M]
1. [MCQ] [GATE-2023 : 2M] In a pushdown automaton P = (Q, Σ, Γ, δ, q0, F), a
Consider the pushdown automaton (PDA) P below, transition of the form,
which runs on the input alphabet {a, b}, has stack
alphabet {⊥, A}, and has three states {s, p, q}, with
s being the start state. A transition from state u to
state v, labelled c/X/γ, where c is an input symbol or where p, q  Q, a  Σ  {}, and X, Y  Γ  {},
, X is a stack symbol, and γ is a string of stack represents
symbols, represents the fact that in state u, the PDA
(q, Y)  (p,a,X)
can read c from the input, with X on the top of its
Consider the following pushdown automaton over
stack, pop X from the stack, push in the string γ on
the stack, and go to state v. In the initial the input alphabet  = {a, b} and stack alphabet Γ =
configuration, the stack has only the symbol ⊥ in it. {#, A}.
The PDA accepts by empty stack.

The number of strings of length 100 accepted by the


above pushdown automaton is _____.

3. [MCQ] [GATE-2016 : 2M]


Consider the transition diagram of a PDA given
below with input alphabet  = {a, b}and stack
alphabet  = {X, Z}. Z is the initial stack symbol.
Let L denote the language accepted by the PDA
Which one of the following options correctly
describes the language accepted by P?
(a) {am bn | 1 ≤ m and n < m}
(b) {am bn | 0 ≤ n ≤ m}
(c) {am bn | 0 ≤ m and 0 ≤ n}
(d) {am | 0 ≤ m}  {bn |0 ≤ n} Which one of the following is TRUE?

8.24
GATE Wallah CS & IT Topic wise PYQs
Context Free Language and Context Free Grammar

(a) L = {an bn | n ≥ 0}and is not accepted by any X → aX | a


finite automata Y → aYb | 
(b) L = {an | n ≥ 0}  {anbn | n ≥ 0} and is not (a) {ambn | m > n, n > 0}
accepted by any deterministic PDA
(b) {ambn | m > n, n  0}
(c) L is not accepted by any Turing machine that
halts on every input (c) {ambn | m  n, n  0}
(d) L = {an | n ≥ 0}  {anbn | n ≥ 0} and is (d) {ambn | m  n, n > 0}
deterministic context – free
7. [MCQ] [GATE-2017 : 1M]
4. [MCQ] [GATE-2015 : 2M] Consider the following context - free grammar over
Consider the NPDA Q = {q0, q1, q2}, the alphabet Σ = {a, b, c} with S as the start symbol:
S → abScT | abcT
 = {0, 1},  = {0, 1, ⊥}, , q0 , ⊥,F = {q2} 
where (as per usual convention) Q is the set of states, T → bT | b
 is the input alphabet,  is stack alphabet,  is the Which one of the following represents the language
state transition function, q0 is the initial state, ⊥ is generated by the above grammar
the initial stack symbol, and F is the set of accepting (a) {(ab)n(cb)n | n ≥ 1}
states, The state transition is as follows: (b) {(ab)n cbm1 cbm2 ......cbmn | n, m1, m2 .....mn  1}
(c) {(ab)n(cbm)n | m, n ≥ 1}
(d) {(ab)n(cbn)m | m, n ≥ 1}

8. [MCQ] [GATE-2017 : 2M]


Consider the context-free grammars over the
alphabet {a, b, c} given below. S and T are non-
Which one of the following sequences must follow
terminals.
the string 101100 so that the overall string is
G1: S → aSb | T, T→cT|
accepted by the automaton?
(a) 10110 (b) 10010 G2: S → bSa | T, T→cT|
(c) 01010 (d) 01001 The language L(G1)  L(G2) is
(a) Finite.
Context Free Grammar (b) Not finite but regular.
5. [MCQ] [GATE-2017 : 2M] (c) Context - Free but not regular.
If G is a grammar with productions (d) Recursive but not context-free.
S → SaS | aSb | bSa | SS|
Where S is the start variable, then which one of the 9. [MCQ] [GATE-2016 : 2M]
following strings is not generated by G? Which one of the following grammars is free from
(a) abab (b) aaab left recursion?
(c) abbaa (d) babba (a) S → AB (b) S → Ab | Bb | c
A → Aa | b A → Bd | 
B→c B→e
6. [MCQ] [GATE-2017 : 1M]
Identify the language generated by the following (c) S → Aa | B (d) S → Aa | Bb | c
grammar, where S is the start variable. A → Bb |Sc |  A → Bd | 
S → XY B→d B → Ae | 

8.25
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

10. [MCQ] [GATE-2016 : 2M] 13. [MCQ] [GATE-2008 : 2M]


Consider the following context-free grammars: For the correct answer in above Question, how many
G1: S → aS | B steps are required to derive the string “aabbaab” and
B → b | bB how many parse trees are there?
G2: S → aA | bB (a) 6 and 1 (b) 6 and 2
A → aA | B |  (c) 7 and 2 (d) 4 and 2
B → bB | 
Which one of the following pairs of languages is 14. [MCQ] [GATE-2008 : 2M]
generated by G1 and G2 respectively? Consider a CFG with the following productions.
(a) {am bn│m > 0 or n > 0} and {am bn |m >0 and S → AA | B
n > 0} A → 0A | A0 |1
(b) {am bn│m > 0 and n > 0} and {am bn |m > 0 or
B → 0B00 | 1
n ≥ 0}
S is the start symbol, A and B are non-terminals and
(c) {am bn│m ≥ 0 or n > 0}and {am bn |m > 0 and
0 and 1 are the terminals. The language generated by
n > 0} this grammar is
(d) {am bn│m ≥ 0 and n > 0} and {am bn |m > 0 or
(a) {0n102n | n ≥ 1}
n > 0}
(b) {0i10j10k│i, j, k ≥ 0} ∪ {0n102n | n ≥ 0}

11. [MCQ] [GATE-2009 : 1M] (c) {0i10j│i, j ≥ 0} ∪ {0n102n |n ≥ 0}

S → aSa | bSb | a | b (d) The set of all strings over {0, 1} containing at
least two 0’s
The language generated by the above grammar over
the alphabet {a, b} is the set of
15. [MCQ] [GATE-2008 : 2M]
(a) All palindromes
Which of the following statements are true?
(b) All odd length palindromes
1. Every left – recursive grammar can be
(c) Strings that begin and end with the same
converted to a right – recursive grammar and
symbol
vice-versa
(d) All even length palindromes
2. All  - productions can be removed from any
context – free grammar by suitable
Common data for question 12 and 13.
transformations
A CFG G is given with the following productions where
S is the start symbol, A is a non-terminal and a and b are 3. The language generated by a context-free
terminals. grammar all of whose productions are of the
S → aS | A form X → w or wY (where, w is a string of
terminals and Y is a non-terminal), is always
A → aAb | bAa | 
regular
12. [MCQ] [GATE-2008 : 2M] 4. The derivation trees of strings generated by a
Which of the following strings is generated by the context-free grammar in Chomsky Normal
grammar above? Form are always binary trees
(a) aabbaba (b) aabaaba (a) 1, 2, 3 and 4
(c) abababb (d) aabbaab (b) 2, 3 and 4 only
(c) 1, 3 and 4 only
(d) 1, 2 and 4 only

8.26
GATE Wallah CS & IT Topic wise PYQs
Context Free Language and Context Free Grammar

Context Free Language Identification Which of the above statements is/are TRUE?
16. [MSQ] [GATE-2022 : 2M] (a) I only (b) II only
Consider the following languages: (c) I and III only (d) III only
L1 = {an wan | w  {a, b}*}
20. [MCQ] [GATE-2020 : 2M]
L2 = {wxwR | w, x{a, b}* , |w|, |x| > 0}
Consider the following languages.
Note that wR is the reversal of the string w. Which of
the following is/are TRUE? L1 = {wxyx | w, x, y  (0 + 1)+}
(a) L1 and L2 are regular L2 = {xy | x, y  (a + b)*, |x| = |y|, x  y}
(b) L1 and L2 are context – free Which one of the following is TRUE?
(c) L1 is regular and L2 is context – free (a) L1 is regular and L2 is context-free.
(d) L1 and L2 are context – free but not regular (b) L1is context-free but L2 is not context-free.
(c) Neither L1 nor L2 is context-free.
17. [MSQ] [GATE-2022 : 2M] (d) L1 is context-free but not regular and L2 is
Consider the following languages: context-free.
L1 = {ww | w  {a, b}*}
L2 = {anbncm | m, n  0} 21. [MCQ] [GATE-2019 : 2M]
L3 = {ambncn | m, n  0} Which one of the following language over
 = {a, b} is NOT context – free?
Which of the following statements is/are FALSE?
(a) {wwR | w{a, b}*}
(a) L1 is not context – free but L2 and L3 are
deterministic context – free. (b) {wan bn wR│w  {a, b}*, n ≥ 0}
(b) Neither L1 nor L2 is context – free. (c) {wan wR bn | w  {a, b}*, n ≥ 0}
(c) L2, L3 and L2  L3 all are context – free. (d) {an bi│i  {n, 3n, 5n}, n ≥ 0}
(d) Neither L1 nor its complement is context – free.
22. [MCQ] [GATE-2018 : 2M]
18. [MSQ] [GATE-2021 : 2M] Consider the following languages:
For a string w, we define wR to be the reverse of w. I. {am bn cp dq |m + p = n + q,
For example, if w = 01101 then wR = 10110. where m, n, p, q ≥ 0}
Which of the following languages is/are context- II. {am bn cp dq |m = n and p = q,
free? where m, n, p, q ≥ 0}
(a) {w x wR xR | w, x {0, 1}*} III. {am bn cp dq |m = n = p and p ≠ q,
(b) {w wR x xR | w, x {0, 1}*} where m, n, p, q ≥ 0}
(c) {w x wR | w, x {0, 1}*} IV. {am bn cp dq |mn = p + q, where m, n, p, q ≥ 0}
(d) {w x xRwR | w, x{0, 1}*] Which of the languages above are context-free?
(a) I and IV only (b) I and II only
(c) II and III only (d) II and IV only
19. [MCQ] [GATE-2020 : 1M]
Consider the language L = {an | n  0}  {an bn |
n  0} and the following statements
23. [MCQ] [GATE-2016 : 2M]
I. L is deterministic context-free Consider the following languages:
II. L is context-free but not deterministic L1 = {an bm cn + m : m, n ≥ 1}
context-free L2 = {an bn c2n : n ≥ 1} Which one of the following is
III. L is not LL(k) for any k. TRUE?

8.27
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

(a) Both L1 and L2 are context-free. L3 = {0i 1j│i = 2j + 1}


(b) L1 is context-free while L2 is not context-free. L4 = {0i1j |i ≠ 2j}
(c) L2 is context-free while L1 is not context-free. Which one of the following statements is true?
(d) Neither L1 nor L2 is context-free. (a) Only L2 is context free
(b) Only L2 and L3 are context free
24. [MCQ] [GATE-2015 : 1M] (c) Only L1 and L2 are context free
Which of the following languages are context-free (d) All are context free
L1 = {am bn an bm | m, n ≥ 1}
L2 = {am bn am bn│m, n ≥ 1} 28. [MCQ] [GATE-2008 : 2M]
L3 = {am bn | m = 2n + 1} Consider the following languages.
L1 = {ai bj ck | i = j, k ≥ 1}
(a) L1 and L2 only (b) L1 and L3 only
L2 = {ai bj | j = 2i, i ≥ 0}
(c) L2 and L3 only (d) L3 only
Which of the following is true?
25. [MCQ] [GATE-2014 : 1M] (a) L1 is not a CFL but L2 is
Which of the following is TRUE? (b) L1  L2 = ϕ and L1 is non-regular
n n
(a) The language L ={a b | n ≥ 0} is regular. (c) L1  L2 is not a CFL but L2 is
(b) The language L = {an | n is prime } is regular (d) There is a 4 state PDA that accepts L1 but there
(c) The language L = {w |w has 3k + 1 b' s for is no DPDA that accepts L2
some k  N with  = {a, b}} is regular.
(d) The language L = {w w | w * with 29. [MCQ] [GATE-2008 : 2M]
 = {0, 1}} is regular. Which of the following languages is (are) non –
regular?

26. [MCQ] [GATE-2014 : 2M] 


L1 = 0m1n | 0  m  n  10000 
Consider the following languages over the alphabet L2 = {reads the same forward and backward}
Σ = {0, 1, c}: L3 = {contains an even number of 0’s and an even
L1 = {0n1n | n ≥ 0} number of 1’s}
(a) L2 and L3 only (b) L1 and L2 only
L2 = {wcwr│w  {0, 1}*}
(c) L3 only (d) L2 only
L3 = {wwr | w  {0, 1}*}
Here, wr is the reverse of the string w. Which of these Closure Properties of Context Free Language
languages are deterministic Context-free languages?
30. [MSQ] [GATE-2021 : 1M]
(a) None of the languages Let L1 be a regular language and L2 be a context-free
(b) Only L1 language. Which of the following languages is/are
(c) Only L1 and L2 context-free?
(d) All the three languages (a) L1  L2

27. [MCQ] [GATE-2010 : 2M] (b) L1  L2


Consider the language (c) L1  (L2  L2 )
L1={0i1j│i ≠ j}
L2 = {0i 1j│i = j}
(
(d) ( L1  L2 )  L1  L2 )

8.28
GATE Wallah CS & IT Topic wise PYQs
Context Free Language and Context Free Grammar

31. [MCQ] [GATE-2021 : 1M] I. L1  L2 II. L1  L2


Suppose that L1 is a regular language and L2 is a
(a) I only (b) II only
context-free language. Which one of the following
languages as NOT necessarily context-free? (c) I and II (d) Neither I nor II
(a) L1  L2 (b) L1 . L2
(c) L1 – L2 (d) L1  L2 34. [MCQ] [GATE-2011 : 1M]
Let P be a regular language and Q be a context free
32. [MCQ] [GATE-2017 : 1M] language such that Q  P. (For example, let P be the
Let L1, L2 be any two context-free languages and R language represented by the regular expression p*q*
be any regular language. Then which of the and Q be {pn qn | n  N}). Then which of the
following is/are CORRECT? following is ALWAYS regular?
I. L1  L2 is context − free (a) P  Q (b) P – Q
(c) Σ* – P (d) Σ* – Q
II. L1 is context − free
III. L1 − R is context − free
35. [MCQ] [GATE-2009 : 1M]
IV. L1  L2 is context − free Which one of the following is FALSE?
(a) I, II and IV only (b) I and III only (a) There is a unique minimal DFA for every
(c) II and IV only (d) I only regular language.
(b) Every NFA can be converted to an equivalent
33. [MCQ] [GATE-2017 : 2M] PDA.
Consider the following languages over the alphabet (c) Complement of every context-free language is
Σ = {a, b, c} recursive.
Let L1 = {an bn cm | m, n ≥ 0} and (d) Every nondeterministic PDA can be converted
L2 ={ambncn | m, n ≥ 0}. to an equivalent deterministic PDA.
Which of the following are context-free languages?

❑❑❑

8.29
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

1. (a) 2. (50 to 50) 3. (d) 4. (b)


5. (d) 6. (b) 7. (b) 8. (b)
9. (b) 10. (d) 11. (b) 12. (d)
13. (a) 14. (b) 15. (c) 16. (a, b, c)
17. (b, c, d) 18. (b, c, d) 19. (c) 20. (a)
21. (c) 22. (b) 23. (b) 24. (b)
25. (c) 26. (c) 27. (d) 28. (b)
29. (d) 30. (b, c, d) 31. (c) 32. (b)
33. (a) 34. (c) 35. (d)

1. (a) • Total number of 100 length strings


State s can push A for each input a, and whenever b = 100 – 51 + 1 = 50
comes as input, it will pop A and then changes to
state p. If end of the input happens from state s, then
it will change to state q and will pop all A’s to make
empty stack.
State p can pop A for each input b, and whenever
end of input reaches, it will change to state q and
pop all A’s from stack to make empty stack.
3. (d)
Case1: a* will be accepted if s and q are involved.
Case2: am bn will be accepted (m > n > 0) if s, p, and
q are involved.
L = {am bn | m > n ≥ 0} = {am bn | m > n, m ≥ 1}
Therefore, option (a) is correct.

State A: For every input a push X (A is final state).


State B: For every input b pop X.
L = {anbn | n  0}  {an | n  0}
2. (50 to 50)
Language by PDA = {am bn | m > n}
• Sum of a’s and b’s must be 100
• Possible strings are: a100 b0, a99 b1, a92 b2, ….,
a51 b49.

8.30
GATE Wallah CS & IT Topic wise PYQs
Context Free Language and Context Free Grammar

4. (b) (b) aaab


q0 :

0, z → 0z; Push 0 for input 0

1, z → 1z; Push 1 for input 1

0/1/, z → z; no operation
q1 :

1, 0z → z; pop 0 for input 1

0, 1z → z; pop 1 for input 0 (c) abbaa


• String = 101100

10110010010

Last 5 bits = 10010 6. (b)


Y = an bn
Hence, option (b) is correct.
X = a+
S = a+ an bn | n  0
Hence, L = {am bn | m, n  0 and m >n}
= {am bn | m > n  0}

5. (d)
(a) abab
7. (b)
T → bT | b
T = b+
S → abScT | abcT
S = abS cb+ | abcb+
= {abn abcb+ (cb+)n | n > 0 }

8.31
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

Minimal string = abcb+ (d) S → Aa | Bb | c


L = {(ab)n (cb+)n | n > 0} A → Bd | 
= (ab)n cbm1 cbm2 ..... n times B → Ae | 
A → B → A indirectly there is a left
 
= (ab)n cbm1 cbm2 cbm3 .... cbmn | n,m1,m2 .....mn  1
recursion A to A.

8. (b) 10. (d)


G1: S → aSb | T • G1: S → aS | B
T → c T |  = c* B → b | bB
L(G1) = {a c* b | n  0}
n n
B = b+
G2: S → bSa | T S = a*b+

T → c T |  = c* L1 = {am bn│m ≥ 0 and n > 0}

L(G2) = {bnc* an | n  0} • G2: S → aA | bB


L(G1)  L(G2) = {c*} A → aA | B | 
It is a regualr but infinite(Not finite). B → bB | 
Hence, option (b) is correct. B = b*
A = a*b*
S = aa*b* | bb*
L2 = a+ b*  b+
L2 = {am bn |m > 0 or n > 0}
Hence, option (d) is correct.
9. (b)
(a) S → AB
A → Aa | b
B→c
A → A there is a left recursion A to A.

(b) S → Ab | Bb | c
11. (b)
A → Bd | 
B→e • S → aSa | bSb | a | b
There is not left recursion. This grammar will generate all odd length
palindrome strings.
(c) S → Aa | B
A → Bb |Sc | 
B→d
S → A → S indirectly there is a left
recursion S to S.

8.32
GATE Wallah CS & IT Topic wise PYQs
Context Free Language and Context Free Grammar

12. (d) B = 0n102n


S → aS | A A → 0A | A0 |1
A → aAb | b A a |  A = 0*10*
(a) aabbaba → Not Possible. S → AA | B
S = {0*10*0*10*}  {0n102n}
(b) aabaaba → Not Possible.
= {0*10*10*}  {0n102n}
(c) abababb → Not Possible.
• 0*10*10* = {0i10j10k│i, j, k ≥ 0}
(d) aabbaab → Possible.
• 0n102n = {0n102n | n ≥ 0}
Hence, option (d) is correct.

13. (a) 15. (c)


S → aS | A
1. Every left – recursive grammar can be
A → aAb | bAa |  converted to a right – recursive grammar and
vice-versa. TRUE
2. All  - productions can be removed from any
context – free grammar by suitable
transformations. FALSE
3. The language generated by a context-free
grammar all of whose productions are of the
form X → w or wY (where, w is a string of
terminals and Y is a non-terminal), is always
regular. TRUE
4. The derivation trees of strings generated by a
context-free grammar in Chomsky Normal
Form are always binary trees. TRUE

S → aS → aA → aaAb → aabAab → aabbAaab


→ aabbaab
Total number of steps = 6 and 1 Parse Tree. 16. (a, b, c)
• L1= {an wan | w{a, b}* }
Assume n = 0
L1 = .w.
= w = {a, b}*
14. (b) = (a + b)* Regular
B → 0B00 | 1 • L2 = {wxwR | w, x{a, b}*, |w|, |x| > 0}

8.33
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

OR 19. (c)
= {wxwR | w, x{a, b}+} I. L is deterministic context-free (True)
It is well known regular language. II. L is context-free but deterministic context-free
Every regular language is also CFL. (False)
Hence, option (a, b, c) are correct. Regular  DCFL = DCFL
DPDA:

17. (b, c, d)
L1 = {ww | w  {a, b}*}  CSL
L2 = {an bn cm | m, n  0}  an bn c*  DCFL
L3 = {am bn cn | m, n  0} a* bn cn  DCFL
• Every DCFL language is CFL also III. L is not LL(k) for any k. (True)
• DCFL  DFCL
an bn c* a* bn cn
= an bn cn = CSL
L1 = ww = CFL 20. (a)
L1 = wxwy
Put minimum string in x = 0 or 1
• L1 = w0y0 + w1y1
( 0 + 1)+ 0 ( 0 + 1)+ 0 + ( 0 + 1)+ 1( 0 + 1)+ 1 is
18. (b, c, d) Regular
• L2 = CFL language
(a) Not CFL

(b) CFL

(c) .x. = x = (0 +1)* = Regular


21. (c)
Regular means CFL also (a) {wwR | w{a, b}*}. CFL
(b) {wan bn wR│w  {a, b}*, n ≥ 0}. CFL
(d) CFL
(c) {wan wR bn | w  {a, b}*, n ≥ 0} . Not CFL
Hence, option (b, c, d) are correct.
(d) {an bi│i  {n, 3n, 5n}, n ≥ 0}. CFL

8.34
GATE Wallah CS & IT Topic wise PYQs
Context Free Language and Context Free Grammar

22. (b) (c) The language L = {w |w has 3k + 1 b' s for


I. m n p q
{a b c d |m + p = n + q} is CFL some k  N with  = {a, b}} is regular. True

II. L = am bn cb dq is CFL. (d) The language L = {w w | w * with


 = {0, 1}} is regular. False

III. {am bn cp dq |m = n = p and p ≠ q}. PDA not


exist. So,it is not CFL.
IV. {am bn cp dq |mn = p + q, where m, n, p, q ≥ 0}.
It is also not CFL.
Hence, option (b) is correct. 26. (c)
Σ = {0, 1, c}
L1 = {0n1n | n ≥ 0}  DCFL
L2 = {wcwr│w  {0, 1}* }  DCFL
L3 = {wwr | w{0, 1}*} CFL but not DCFL
23. (b)
• L1 = {an bm cn + m | m, n  1}
= {an bm cm cn | m, n  1}
L1 is CFL.
27. (d)
• L2 = {an bn c2n | n  1}
L1={0i1j│i ≠ j} = DCFL
= CSL but Not CFL.
L2 = {0i 1j│i = j} = DCFL
Hence, option (b) is correct.
L3 = {0i 1j│i = 2j + 1}= DCFL
L4 = {0i1j |i ≠ 2j}= DCFL
All are DCFLs and every DCFL is CFL.

24. (b)
L1 = {am bn an bm | m, n ≥ 1}= CFL
L2 = {am bn am bn│m, n ≥ 1} = Not CFL 28. (b)
L3 = {am bn |m = 2n + 1} = CFL L1={ai bj ck |i = j, k ≥ 1}  an bn c+ = DCFL
L2 = {ai bj |j = 2i, i ≥ 0} ak b2k = DCFL
Every DCFL is CFL.
• L1  L2 = 
• L1  L2 = CFL
• L2 is a DCFL. So, DPDA possible.
25. (c)
Hence, option (b) is correct.
(a) The language L ={an bn | n ≥ 0} is regular.
False
(b) The language L = {an | n is prime } is regular.
False

8.35
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

29. (d) 32. (b)


 m n

L1 = 0 1 | 0  m  n  10000 Finite L1 = CFL, L2 = CFL and R = Regular language
L2 = {reads the same forward and backward} I. CFL1  CFL2  CFL
Set of all palindrome (CFL)
II. CFL CSL
L3 = {contains an even number of 0’s and an even
number of 1’s} Regular III. CFL – Regular = CFL  Regular
L2 is not a regular.
= CFL  Regular = CFL
Hence, option (d) is correct.
IV. CFL1  CFL2  CSL
• CFL is not closed under compliment and
intersection.

30. (b, c, d)
L1 = Regular, L2 = CFL

(a) Regular  CFL = may/may not be CFL.

(b) Regular  CFL = Regular  CFL = CFL 33. (a)

(c) Regular  (CFL  CFL ) = Regular  * = * L1 = {an bn cm | m, n ≥ 0} = CFL

(d) ( Regular  CFL )  (Regular  CFL) L2 ={am bn cn | m, n ≥ 0} = CFL


I. L1  L2  CFL  CFL = CFL
= CFL  CFL = CFL
II. L1  L2 = {an bn c*  a* bn cn}
• Every Regular is CFL
Hence, option (b, c, d) are correct. = {an bn cn | n  0}  CSL

31. (c)
34. (c)
L1  Regular
A. Regular  CFL  CFL
L2  CFL
B. Regular – CFL
(i) L1  L2  Reg  CFL  CFL
Regular  CFL  need not be regular
(ii) L1 . L2  Reg CFL  CFL
C. * – Regular  Regular
(iii) L1 – L2  Reg – CFL  Reg  CFL  CSL D. * – CFL  need not be regular
(iv) L1  L2  Reg  CFL  CFL Hence, option (c) is correct.

8.36
GATE Wallah CS & IT Topic wise PYQs
Context Free Language and Context Free Grammar

35. (d) • Every nondeterministic PDA can be converted


• For Regular language minimal DFA is unique. to an equivalent deterministic PDA.
• Every NFA can be converted to an equivalent
PDA.
• CFL = CSL
Every CSL is recursive.

❑❑❑

8.37
GATE Wallah CS & IT Topic wise PYQs
Design of springs

CHAPTER

5
Turing Machine (a) Both 2* and * is countable
1. [MCQ] [GATE-2019 : 2M] (b) 2* is countable and * is uncountable
Consider the following sets: (c) 2* is uncountable and * is countable
S1: Set of all recursively enumerable languages (d) Both 2* and * are uncountable
over the alphabet {0, 1} 4. [MCQ] [GATE-2011 : 1M]
S2: Set of all syntactically valid C programs Which of the following pairs have DIFFERENT
expressive power
S3: Set of all languages over the alphabet {0, 1}
(a) Deterministic finite automata (DFA) and Non-
S4: Set of all non-regular languages over the
deterministic finite automata (NFA)
alphabet 0, 1}
(b) Deterministic push down automata (DPDA) and
Which of the above sets are uncountable? Non-deterministic push down automata (NPDA)
(a) S1 and S2 (b) S3 and S4 (c) Deterministic single-tape Turing machine and
(c) S2 and S3 (d) S1 and S4 Non-deterministic single – tape Turing machine
(d) Single-tape Turing machine and multi-tape
2. [MCQ] [GATE-2017 : 2M] Turing machine
Let A and B be finite alphabets and let # be a symbol 5. [MCQ] [GATE-2011 : 2M]
outside both A and B. Let f be a total function from Consider the languages L1, L2 and L3 are given
A* to B*. We say f is computable if there exists a below:
Turing machine M which given an input x in A*, L1 = {0p 1q│p, q  N},
always halts with f(x) on its tape. Let Lf denote the L2 = {0p 1q│p, q  N and p = q} and
language {x # f(x)|x  A*}. Which of the following L3 = {0p 1q 0r | p, q, r  N and p = q = r}
statements is true? Which of the following statements is NOT TRUE?
(a) f is computable if and only if Lf is recursive. (a) Push Down Automata (PDA) can be used to
(b) f is computable if and only if Lf is recursively recognize L1 and L2
enumerable. (b) L1 is a regular language
(c) All the three languages are context free
(c) If f is computable then Lf is recursive, but not
(d) Turing machines can be used to recognize all
conversely.
the languages
(d) If f is computable then Lf is recursively
6. [MCQ] [GATE-2008 : 1M]
enumerable, but not conversely.
Which of the following is true for the language {ap |
p is a prime number}?
3. [MCQ] [GATE-2014 : 1M] (a) It is not accepted by a Turning Machine
Let  be a finite non-empty alphabet and let 2* be (b) It is regular but not context-free
the power set of *. Which one of the following is (c) It is context-free but not regular
TRUE? (d) It is neither regular nor context-free, but
accepted by a Turing machine
8.38
GATE Wallah CS & IT Topic wise PYQs
Turing Machine (Recursive and RELs)

Recursive and RE Language Identification List-I


7. [MSQ] [GATE-2023 : 1M] A. Checking that identifier are declared before their
Which of the following statements is/are correct? use
B. Number of formal parameters in the declaration
(a) The intersection of two redular languages is
of a function agrees with the number of actual
regular.
parameters in a use of that function
(b) The intersection of two context-free languages
C. Arithmetic expressions with matched pairs of
is context-free.
parentheses
(c) The intersection of two recursive languages is D. Palindromes
recursive.
List-II
(d) The intersection of two recusively enumerable
1. L = a n bm cn d m | n  1,m  1
languages is recursively enumerable.
2. X → XbX | XcX | dXf | g
8. [MCQ] [GATE-2017 : 2M]
Consider the following languages:
3. 
L = wcw|w  ( a|b )
*

4. X → bXb | cXc | 
L1 = {aP |p is a prime number}
L2 = {an bm c2m | n ≥ 0, m ≥ 0} Codes:
a b c d
L3 = {an bn c2n | n ≥ 0}
(a) 1 3 2 4
L4 = {an bn | n ≥ 1}
(b) 3 1 4 2
Which of the following are CORRECT?
(c) 3 1 2 4
I. L1 is context-free but not regular.
(d) 1 3 4 2
II. L2 is not context-free.
III. L3 is not context-free but recursive.
Closure Properties of Recursive and Rels
IV. L4 deterministic context-free.
11. [MSQ] [GATE-2022 : 1M]
(a) I, II and IV only Which of the following statements is / are TRUE?
(b) II and III only (a) Every subset of a recursively enumerable
(c) I and IV only language is recursive.
(d) III and IV only (b) If a language L and its complement L are both
recursively enumerable, then L must be
recursive.
9. [MCQ] [GATE-2013 : 2M] (c) Complement of a context-free language must be
Consider the following languages recursive.
L1 = {0p1q0r | p, q, r ≥ 0} (d) If L1 and L2 are regular, then L1  L2 must be
L2 = {0p1q0r | p, q, r ≥ 0 p ≠ r} deterministic context – free.
Which one of the following statements is FALSE?
(a) L2 is context-free 12. [MCQ] [GATE-2021 : 1M]
(b) L1  L2 is context-free Let <M> denote an encoding of an automaton M.
(c) Complement of L2 is recursive Suppose that Σ = {0, 1}. Which of the following
(d) Complement of L1 is context-free but not languages is/are NOT recursive?
regular (a) L = {<M> | M is a DFA such that L(M) = ∅}
10. [MCQ] [GATE-2008 : 2M] (b) L = {<M> | M is a DFA such that L(M) = Σ*}
Match List-I with List-II and select the correct (c) L = {<M> | M is a PDA such that L(M) = ∅}
answer using the codes given below the lists: (d) L = {<M> | M is a PDA such that L(M) = Σ*}

8.39
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

13. [MCQ] [GATE-2018 : 1M] 17. [MCQ] [GATE-2010 : 1M]


The set of all recursively enumerable languages is Let L1 be a recursive language. Let L2 and L3 be
(a) Closed under complementation. language that are recursively enumerable but not
(b) Closed under intersection. recursive. Which of the following statements is not
(c) A subset of the set of all recursive language. necessarily true?
(d) An uncountable set. (a) L2 – L1 is recursively enumerable
14. [MCQ] [GATE-2016 : 1M] (b) L1 – L3 is recursively enumerable
Consider the following types of languages: (c) L2  L3 is recursively enumerable
L1: Regular, L2: Context-free, L3: Recursive, (d) L2  L3 is recursively enumerable
L4: Recursively enumerable.
Which of the following is/are TRUE?
18. [MCQ] [GATE-2009 : 2M]
I. L 3  L4 is recursively enumerable.
Let L = L1  L2, where L1 and L2 are languages as
II. L 2  L3 is recursive.
defined below:
III. L1*  L2 is context-free.
L1 = {am bm can bn | m, n ≥ 0}
IV. L1  L 2 is context-free.
L2 = {aibjck | i, j, k ≥ 0}
(a) I only (b) I and III only
Then L is
(c) I and IV only (d) I, II and III only
(a) Not recursive
(b) Regular
15. [MCQ] [GATE-2015 : 1M]
(c) Context-free but not regular
For any two languages L1 and L2 such that L1 is
context free and L2 is recursively enumerable but (d) Recursively enumerable but not context-free
not recursive, which of the following is/are
necessarily true? 19. [MCQ] [GATE-2008 : 2M]
I. L1 (complement of L1) is recursive Which of the following statements is false?
II. L 2 (complement of L2) is recursive (a) Every NFA can be converted to an equivalent
III. L1 is context-free DFA.
(b) Every non-deterministic Turing machine can be
IV. L1  L2 is recursively enumerable
converted to an equivalent deterministic Turing
(a) 1 only (b) 3 only
machine.
(c) 3 and 4 only (d) 1 and 4 only (c) Every regular language is also a context-free
language.
16. [MCQ] [GATE-2014 : 2M] (d) Every subset of a recursively enumerable set is
Let L be a language and L be its complement. Which recursive.
one of the following is NOT a viable possibility?
(a) Neither L nor L is recursively enumerable (r.e.).
20. [MCQ] [GATE-2008 : 1M]
(b) One of L and L is r.e. but not recursive; the
If L and L are recursively enumerable then L is
other is not r.e.
(a) regular (b) context-free
(c) Both L and L are r.e. but not recursive.
(c) context-sensitive (d) recursive
(d) Both L and L are recursive.

❑❑❑

8.40
GATE Wallah CS & IT Topic wise PYQs
Turing Machine (Recursive and RELs)

1. (b) 2. (a, d) 3. (c) 4. (b)


5. (c) 6. (d) 7. (a, c, d) 8. (d)
9. (d) 10. (c) 11. (b, c, d) 12. (d)
13. (b) 14. (d) 15. (d) 16. (c)
17. (b) 18. (c) 19. (d) 20. (d)

• If L is REL then f may/may not be computable.


1. (b)
• If f is computable then Lf is recursively
S1: Set of all recursively enumerable languages
enumerable, but not conversely.
over the alphabet {0, 1}
Set of RELs is Countable.
S2: Set of all syntactically valid C programs
All C, C++, Java, etc. are Countable.
S3: Set of all languages over the alphabet {0, 1}
Set of all languages = 2* is Uncountable.
3. (c)
S4: Set of all non-regular languages over the
alphabet {0, 1} • * = Set of all strings = Regular
Regular is countable.
Set of all regular languages is Countable but set of
all non-regular language is Uncountable. • 2* = Set of all languages
Set of all languages is uncountable.
Hence, option (c) is correct.

2. (a, d)
f
A* ⎯
⎯⎯⎯
⎯→ B* 4. (b)
a1 → f (a1) = b1 • DFA ≡ NFA
a2 → f (a2) = b2 • DPDA  NPDA
a3 → f (a3) = b3 • DTM ≡ NTM whether it is a single tape or
a4 → f (a4) = b4 multi tape.
  
Lf = {a1# f(a1), a2 #, f(a2)……. }
• Lexicographical order is possible. So, Lf is
recursive.

8.41
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

5. (c) 9. (d)
L1 = {0 1 │p, q  N} 0 1  Regular
p q * *
• L1 = {0p1q0r | p, q, r ≥ 0}
L2 = {0p1q│p, q  N and p = q} and  DCFL = 0*1*0* is Regular language
L3 = {0p1q0r |p, q, r  N and p = q = r}  CSL • L2 = {0p1q0r | p, q, r ≥ 0 p ≠ r}
Hence, option (c) is correct.
= DCFL language
• L1  L2 = Regular  DCFL = DCFL
• DCFL = DCFL
• Regular = Regular
6. (d)
• {ap | p is a prime number} it is a CSL language.
Every CSL is recursive and RE.
Hence, option (d) is correct.

10. (c)
List-I List-II
7. (a, c, d) A. Checking that
identifier are declared

3. L = wcw|w  ( a|b )
*

(a) The intersection of two redular languages is
regular. before their use
Reg  Reg  Reg True B. Number of formal 1. L = a n bm cn d m | n  1,m  1
(b) The intersection of two context-free languages parameters in the
is context-free. declaration of a
CFL  CFL  CSL False function agrees with
(c) The intersection of two recursive languages is the number of actual
recursive. parameters in a use of
Rec  Rec  Rec True that function
(d) The intersection of two recusively enumerable C. Arithmetic 2. X → X b X | X c X | d X f | g
languages is recursively enumerable. expressions with
REL  REL  REL True matched pairs of
parentheses
D. Palindromes 4. X → bXb | cXc | 

Hence, option (c) is correct.

8. (d)
L1 = {aP |p is a prime number}  Not CFL
L2 = {an bm c2m | n ≥ 0, m ≥ 0}  DCFL
L3 = {an bn c2n | n ≥ 0}  Not CFL
L4 = {an bn |n ≥ 1}  DCFL 11. (b, c, d)
(a) Every subset of a recursively enumerable
language is recursive. FALSE
Because subset is not closed under any
language.

8.42
GATE Wallah CS & IT Topic wise PYQs
Turing Machine (Recursive and RELs)

(b) If a language L and its complement L are both Hence, option (d) is correct.
recursively enumerable, then L must be
recursive. TRUE
(c) CFL = CSL
Every CSL is recursive and recursive
enumerable.
15. (d)
(d) Regular  Regular = Regular
L1 : CFL
Every Regular language is DCFL, CFL,
Recursive and RE. L1 : RE but not Recursive
I. CFL = CSL
Every CSL is recursive and recursive
enumerable.
II. RE but not Recursive = NOT RE
12. (d)
(a) Emptiness for DFA is decidable (Recursive). III. CFL = CSL (may/may not be CFL) but it will
(b) Totality for DFA is decidable (Recursive). be CSL
(c) Emptiness for PDA is decidable (Recursive). IV. CFL  RE = CSL  RE = RE
(d) Totality for PDA is undecidable (Not
Recursive).

16. (c)

13. (b) (a) Neither L nor L is recursively enumerable


The set of all recursively enumerable language is (r.e.).
Countable and closed under Intersection but not It is possible that both L and L are not RELs.
closed under Complementation. (b) One of L and L is r.e. but not recursive; the
The set of all RELs is superset of Set of all other is not r.e.
recursive languages.
If L is RE but not REC, then L is always NOT
RE.
(c) It is impossible to have both L and L are r.e.
but not recursive.
(d) Both L and L are recursive.
14. (d) If L is recursive, L must be recursive.
Hence, option (c) is correct.
• Recursive  RE = Recursive  RE = RE .
• CFL  Recursive = CSL  Recursive = Recursive.
• (Regular)*  CFL = Regular  CFL = CFL.
• Regular  CFL = Regular  CSL = CSL

8.43
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

17. (b) Hence, option (c)is correct


L1 = Recursive
L2 = RE but not Recursive
L3 = RE but not Recursive
• L2 – L1 = L2  L1
= RE but not Recursive  Recursive
= RE 19. (d)
• L1 – L3 = L1  L3 Subset is not closed under any language.
= L1  NOT REL Hence, option (d) is correct.
= Need not be RE
• RE but not Rec  RE but not Rec = RE.
• RE but not Rec  RE but not Rec = RE.

20. (d)
L and L are recursively enumerable if and only if L
is recursive.
18. (c) Hence, option (d) is correct.
• L1 = {am bm can bn | m, n ≥ 0}
= CFL
• L2 = {aibjck | i, j, k ≥ 0}
=a*b*c* = Regular
• L = L1  L2
= am bm c = DCFL
❑❑❑

8.44
GATE Wallah CS & IT Topic wise PYQs
Design of springs

CHAPTER

6
Undecidability Which one of the following options is correct?
1. [MSQ] [GATE-2022 : 2M] (a) Both L1 and L2 are decidable.
Which of the following is/are undecidable? (b) L1 is decidable and L2 is undecidable.
(a) Given two Turing machines M1 and M2, decide (c) L1 is undecidable and L2 is decidable.
if L(M1) = L(M2). (d) Both L1 and L2 are undecidable.
(b) Given a Turing machine M, decide if L(M) is
regular. 4. [MCQ] [GATE-2020 : 2M]
Which of the following languages are undecidable?
(c) Given a Turing machine M, decide if M accepts
all strings. Note that 〈M〉 indicates encoding of the Turing
machine M.
(d) Given a Turing machine M, decide if M takes
more than 1073 steps on every string. L1 = {〈M〉|L(M) = ϕ}
L2 = {〈M, w, q〉|M on input w reaches state q in
2. [MCQ] [GATE-2021 : 2M] exactly 100 steps}
Consider the following two statements about L3 = {〈M〉|L(M) is not recursive}
regular languages:
L4 = {〈M〉|L(M) contains at least 21 members)
S1: Every infinite regular language contains an
(a) L1, L3 and L4 only (b) L2, L3 and L4 only
undecidable language as a subset.
S2: Every finite language is regular. (c) L1 and L3 only (d) L2 and L3 only
Which one of the following choices is correct?
5. [MCQ] [GATE-2018 : 2M]
(a) Only S1 is true
Consider the following problems. L(G) denotes the
(b) Only S2 is true language generated by a grammar G. L(M) denotes
(c) Both S1 are S2 are true the language accepted by a machine M.
(d) Neither S1 nor S2 is true I. For an unrestricted grammar G and a string w,
whether wL(G).
3. [MCQ] [GATE-2021 : 2M] II. Given a Turing Machine M, whether L(M) is
regular.
For a Turing machine M, 〈M〉 denotes an encoding
of M. Consider the following two languages. III. Given two grammars G1 and G2, whether L(G1)
= L(G2).
L1 = {〈M〉|M takes more than 2021 steps on all
IV. Given an NFA N, whether there is a
inputs}.
deterministic PDA P such that N and P accept
L2 = {〈M〉|M takes more than 2021 steps on some
the same language.
input}.
Which one of the following statements is correct?

8.45
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

(a) Only I and II are undecidable L2 = {M|M takes at least 2016 steps on all inputs}.
(b) Only III is undecidable L3 = {M|M accepts }.
(c) Only II and IV are undecidable Where for each Turning machine M, M denotes a
(d) Only I, II and III are undecidable specific encoding of M. Which one of the following
is TRUE?
6. [MCQ] [GATE-2017 : 2M] (a) L1 is recursive and L2, L3 are not recursive.
Let L(R) be the language represented by regular (b) L2 is recursive and L1, L3 are not recursive.
expression R. Let L(G) be the language generated by (c) L1, L2 are recursive and L3 is not recursive.
a context free grammar G. Let L(M) be the language (d) L1, L2, L3 are recursive .
accepted by a Turing machine M.
Which of the following decision problems are 9. [MCQ] [GATE-2015 : 1M]
undecidable? Consider the following statements:
I. Given a regular expression R and a string w, is 1. The complement of every Turning decidable
w  L(R)? language is Turning decidable.
II. Given a context-free grammar G, is L(G) = ϕ? 2. There exists some language which is in NP but
is not Turing decidable.
III. Given a context-free grammar G, is L(G) = Σ*
3. If L is a language in NP, L is Turing decidable.
for some alphabet Σ?
Which of the above statements is/are True?
IV. Given a Turing machine M and a string w, is (a) Only 2 (b) Only 3
w  L(M)?
(c) Only 1 and 2 (d) Only 1 and 3
(a) I and IV only (b) II and III only
(c) II, III and IV only (d) III and IV only 10. [MCQ] [GATE-2014 : 2M]
Which one of the following problems is
7. [MCQ] [GATE-2016 : 1M] undecidable?
Which of the following decision problems are (a) Deciding if a given context-free grammar is
undecidable ambiguous.
I. Given NFAs N1 & N2, is L(N1)  L(N2) = ? (b) Deciding if a given string is generated by a
given context-free grammar.
II. Given a CFG G = (N, , P, S) and a string x 
(c) Deciding if the language generated by a given
*, does x  L(G)? context-free grammar is empty.
III. Given CFGs G1 and G2 is L(G1) = L (G2)? (d) Deciding if the language generated by a given
IV. Given a TM M, is L(M) = Φ? context-free grammar is finite.
(a) I and IV only
(b) II and III only 11. [MCQ] [GATE-2014 : 2M]
Let M be the encoding of a Turing machine as a
(c) III and IV only
string over  = {0, 1}. Let L = {M| M is a Turing
(d) II and IV only
machine that accepts a string of length 2014}. Then,
L is
8. [MCQ] [GATE-2016 : 2M] (a) decidable and recursively enumerable
Consider the following languages: (b) undecidable but recursively enumerable
L1 = {M|M takes at least 2016 steps on some (c) undecidable and not recursively enumerable
input}. (d) decidable but not recursively enumerable

8.46
GATE Wallah CS & IT Topic wise PYQs
Undecidability and Reducibility

12. [MCQ] [GATE-2013 : 2M] 15. [MCQ] [GATE-2008 : 1M]


Which of the following is/are undecidable? Which of the following are decidable?
1. G is CFG. Is L(G) = ϕ? 1. Whether the intersection of two regular
2. G is a CFG. Is L(G) = Σ*? languages is infinite
3. M is a Turing machine. Is L(M) regular? 2. Whether a given context-free language is regular
3. Whether two push-down automata accept the
4. A is a DFA and N is an NFA. Is L(A) = L(N)?
same language
(a) 3 Only
4. Whether a given grammar is context-free
(b) 3 and 4 only
(a) 1 and 2 (b) 1 and 4
(c) 1, 2 and 3 only
(c) 2 and 3 (d) 2 and 4
(d) 2 and 3 only
Reducibility
13. [MCQ] [GATE-2013 : 1M] 16. [MCQ] [GATE-2016 : 2M]
Which of the following statements is/are FALSE? Let X be a recursive language and Y be a recursively
1. For every non-deterministic Turing machine, enumerable but not recursive language. Let W and Z
there exists an equivalent deterministic Turing be two languages such that Y reduces to W, and Z
machine. reduces to X (reduction means the standard many-
2. Turing recognizable languages are closed under one reduction). Which one of the following
union and complementation. statements is TRUE?
3. Turing decidable languages are closed under (a) W can be recursively enumerable and Z is
intersection and complementation. recursive.
4. Turing recognizable languages are closed under (b) W can be recursive and Z is recursively
union and intersection. enumerable.
(c) W is not recursively enumerable and Z is
(a) 1 and 4 only (b) 1 and 3 only
recursive.
(c) 2 only (d) 3 only
(d) W is not recursively enumerable and Z is not
recursive.
14. [MCQ] [GATE-2012 : 1M]
Which of the following problems are decidable? 17. [MCQ] [GATE-2014 : 1M]
1. Does a given program ever produce an output? Let A ≤ m B denotes that language A is mapping
2. If L is a context-free language, then, is L also reducible (also known as many-to-one reducible) to
context-free? language B. Which one of the following is FALSE?
3. If L is a regular language, then, is L also (a) If A ≤ m B and B is recursive then A is
recursive.
regular?
(b) If A ≤ m B and A is undecidable then B is
4. If L is a recursive language, then, is L also
undecidable.
recursive? (c) If A ≤ m B and B is recursively enumerable then
(a) 1, 2, 3, 4 (b) 1, 2 A is recursively enumerable.
(c) 2, 3, 4 (d) 3, 4 (d) If A ≤ m B and B is not recursively enumerable
then A is not recursively enumerable.

❑❑❑

8.47
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

1. (a, b, c) 2. (c) 3. (a) 4. (a)


5. (d) 6. (d) 7. (c) 8. (c)
9. (d) 10. (a) 11. (b) 12. (d)
13. (c) 14. (d) 15. (b) 16. (c)
17. (d)

1. (a, b, c) Verify each string upto 2021 length. If any of these


• Equivalence problem for Turing machine is strings takes more than 2021 steps, it is valid M.
Undecidable.
• Regularity problem for Turing machine is
Undecidable.
• Totality (Completeness) problem for Turing
machine is Undecidable. 4. (a)
• Given a Turing machine M, decide if M takes L1 = {〈M〉|L(M) = ϕ}
more than 1073 steps on every string is Emptiness problem for Turing machine is
Decidable. Undecidable.
L2 = {〈M, w, q〉|M on input w reaches state q in
exactly 100 steps}
For given M, given w, run exactly 100 steps to
check whether q is reachable or not Decidable.
L3 = {〈M〉|L(M) is not recursive)}  Undecidable.
2. (c) L4 = {〈M〉|L(M)contains at least 21 members)}
Both Statements S1 and S2 are correct. |L(M)|  21 non trivial property is Undecidable.

5. (d)
3. (a)
I. Membership problem for an unrestricted
L1 = {〈M〉|M takes more than 2021 steps on all
grammar is Undecidable.
inputs} Decidable.
Verify every string in length 0 to 2021. II. Given a Turing Machine M, whether L(M) is
L2 = {〈M〉|M takes more than 2021 steps on some regular. Non-trivial problem for Turing
input}Decidable. machine is Undecidable.

8.48
GATE Wallah CS & IT Topic wise PYQs
Undecidability and Reducibility

III. Given two grammars G1 and G2, whether 8. (c)


L(G1) = L(G2). Grammar is not given assume • L1 = {M | M takes at least 2016 steps on
unrestricted grammar for an unrestricted some input}. Decidable
grammar equivalence problem is Undecidable. • L2 = {M | M takes at least 2016 steps on all
IV. Given an NFA N, whether there is a inputs}. Decidable
deterministic PDA P such that N and P accept • L3 = {M | M accepts }.
the same language. Decidable Membership problem for Turing machine is
Undecidable.

6. (d)
I. Given a regular expression R and a string w, 9. (d)
is w  L(R)?
Membership problem for Regular is
Decidable.
II. Given a context-free grammar G, is L(G) = ϕ?
Emptines? • Decidable complement is always Decidable.
Membership, finiteness and emptiness • Every NP problem is always Decidable.
problems for CFL are Decidable.
III. Given a context-free grammar G is L(G) = Σ*
for some alphabet Σ?
Totality problem CFL is Undecidable.
10. (a)
IV. Given a Turing machine M and a string w, is
w  L(M)? • Checking ambiguity for grammar is always
Undecidable.
Membership problem for Turing machine is • Membership problem for CFL is Decidable
Undecidable. (using CYK algorithm).
• Emptiness problem for CFL is Decidable.
• Finiteness problem for CFL is Decidable.

7. (c)
I. Dis-jointness problem for FA is Decidable.
II. Membership problem for CFG is Decidable.
11. (b)
III. Equivalence problem for CFG is Undecidable.
IV. Emptiness problem for TM is Undecidable. • L is undecidable but partially decidable (RE).
Hence, option (c) is correct. Hence, option (b) is correct.

8.49
GATE Wallah CS & IT Topic wise PYQs
Theory of Computation

12. (d) 3. Whether two push-down automata accept the


• Emptiness problem for CFL is Decidable. same language.
• Totality problem for CFL is Undecidable. Equivalence problem for PDA(CFL) is
• Regularity problem for TM is Undecidable. Undecidable.
4. Whether a given grammar is context-free.
• Equivalence problem for Regular is Decidable.
Algorithm exists to identify the context-free
grammar. So this problem is Decidable.

13. (c)
• NTM is equivalent to DTM
16. (c)
• RELs are not closed under complement. X: Recursive
• Recursive languages are closed under both Y: RE but not Recursive
intersection and complement.
• Y  W
• RELs are closed under both union and
intersection. = RE but not Recursive  W
Hence, option (c) is correct. = NOT RE  W
So, W can not be RE
• Z X
= Z  Recursive
14. (d) = Z  Recursive
1. These kind of problems are non-trivial. So, it is So, Z must be Recursive
Undecidable.
2. If L is a context-free language, then, is L also
context-free. It is Undecidable.
3. If L is a regular language, then, is L also
regular. Regular is closed under complement. 17. (d)
So, it is Decidable. Given A ≤ m B
4. If L is a recursive language, then, is L also • If A ≤ m recursive then, A will be recursive.
recursive. It is Decidable. • If Undecidable ≤ m B then, B must be
Undecidable.
• If A ≤ m RE then, A will be RE.
• If A ≤ m NOT RE then, A may/may not be
NOT RE.
15. (b) Hence, option (d) is false statement in given data.
1. Whether the intersection of two regular
languages is infinite.
Infiniteness problem for Regular is Decidable.
2. Whether a given context-free language is
regular. Undecidable
❑❑❑

8.50
GATE Wallah CS & IT Topic wise PYQs

You might also like