Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 115

1.

Let S and T be language over ={a,b} represented by the regular


expressions (a+b*)* and (a+b)*, respectively. Which of the following is
true? (GATE CS 2000)

(a) ScT (S is a subset of T)


(b) TcS (T is a subset of S)
(c) S=T
(d) SnT=Ø
Answer: (c).

2. Let L denotes the language generated by the grammar S – OSO/00.


Which of the following is true? (GATE CS 2000)
(a) L = O
(b) L is regular but not O
(c) L is context free but not regular
(d) L is not context free
Answer: (b)
Explanation: Please note that grammar itself is not regular but language L is
regular as L can be represented using a regular grammar, for example S ->
S00/00.
References:
http://en.wikipedia.org/wiki/Regular_grammar

3. Consider the following two statements:


S1: { 0^2n |n >= l} is a regu1ar language
S2: { 0^m 0^n 0^(m+n) l m >= 1 and n >= 2} is a regu1ar language
Which of the following statements is correct? (GATE CS 2001)
a) Only S1 is correct
b) Only S2 is correct
c) Both S1 and S2 are correct
d) None of S1 and S2 is correct

Answer: (c)
Explanation:
S1 can be written as (00)^n where n >= 1. And S2 can be written as (00)^(m+n)
where m >=2 and n >= 1. S2 can be further reduced to (00)^x where x >= 3.
We can easily write regular grammars for both S1 and S2.
G1 -> G100/00 (For S1)
G2 -> G200/000000 (For S2)

4. Which of the following statements in true? (GATE CS 2001)


(a) If a language is context free it can always be accepted by a deterministic
push-down automaton
(b) The union of two context free languages is context free
(c) The intersection of two context free languages is context free
(d) The complement of a context free language is context free
Answer: (b)
Explanation:
Context-free languages are closed under the following operations. That is, if L
and P are context-free languages and D is a regular language, the following
languages are context-free as well:
• the Kleene star L * of L
• the image Ø(L) of L under a homomorphism Ø
• the concatenation of L and P
• the union of L and P
• the intersection of L with a regular language D (L n D).
Context-free languages are not closed under complement, intersection, or
difference.
Why a) is not true?
The language recognized by deterministic pushdown automaton is deterministic
context free language. Not all context-free languages are deterministic. This is
unlike the situation for deterministic finite automata, which are also a subset of
the nondeterministic finite automata but can recognize the same class of
languages (as demonstrated by the subset construction).
References:
http://en.wikipedia.org/wiki/Context-free_language
http://en.wikipedia.org/wiki/Deterministic_pushdown_automaton

5. Given an arbitrary non-deterministic finite automaton (NFA) with N


states, the maximum number of states in an equivalent minimized DFA is
at least. (GATE CS 2001)
(a) N^2
(b) 2^N
(c) 2N
(d) N!
Answer: (b)
3) Which of the following problems are decidable?
….1) Does a given program ever produce an output?
….2) If L is a context-free language, then is L’ (complement of L) also
context-free?
….3) If L is a regular language, then is L’ also regular?
….4) If L is a recursive language, then, is L’ also recursive?
(A) 1, 2, 3, 4
(B) 1, 2,
(C) 2, 3, 4
(D) 3, 4
Answer (D)
….1) Is a variation of Turing Machine Halting problem and it is undecidable.
….2) Context Free Languages are not closed under intersection and
complement. See this for details.
….3) Complement of Regular languages is also regular. Then a DFA that
accepts the complement of L, i.e. ∑* – L, can be obtained by swapping its
accepting states with its non-accepting states.
….4) Recursive Language s are closed under complement. See this for details.

4) Consider the set of strings on {0,1} in which, every substring of 3


symbols has at most two zeros. For examples, 001110 and 011001 are in
the language, but 100010 is not. All strings of length less than 3 are also
in the language. A partially completed DFA that accepts this language is
shown below.
The missing arcs in the DFA are

Answer (D)
State ‘q’ is trap state. All other states are accept states. In state 00, DFA must
move to ‘q’ for input symbol 0. All (non-trap) states indicate names indicate the
characters seen before reaching that particular state. Option (D) is the only
option that follow these rules.
Please see GATE Corner for all previous year paper/solutions/explanations,
syllabus, important dates, notes, etc.
Please write comments if you find any of the answers/explanations incorrect, or
you want to share more information about the topics discussed above.
1) The lexical analysis for a modern language such as Java needs the
power of which one of the following machine models in a necessary and
sufficient sense?
(A) Finite state automata
(B) Deterministic pushdown automata
(C) Non-deterministic pushdown automata
(D) Turing machine
Answer (A)
Lexical analysis is the first step in compilation. In lexical analysis, program is
divided into tokens. Lexical analyzers are typically based on finite state
automata. Tokens can typically be expressed as different regular expressions:
An identifier is given by [a-zA-Z][a-zA-Z0-9]*
The keyword if is given by if.
Integers are given by [+-]?[0-9]+.

2) Which of the following pairs have DIFFERENT expressive power?


(A) Deterministic finite automata (DFA) and Non-Deterministic finite
automata(NFA)
(B) Deterministic push down automata (DPDA) and Non-deterministic
pushdown automata
(C) Deterministic single-tape Turing machine and Non-deterministic single-tape
Turing Machine
(D) Single-tape Turing machine and multi-tape Turing machine
Answer (B)
DPDA cannot handle languages or grammars with ambiguity, but NDPDA can
handle languages with ambiguity and any context-free grammar.

3) A deterministic finite automation (DFA)D with alphabet ∑= {a,b} is given


below

Which of the following finite state machines is a valid minimal DFA which
accepts the same language as D?

Answer (A)
Options (B) and (C) are invalid because they both accept ‘b’ as a string which is
not accepted by give DFA. D is invalid because it accepts bb+a which are not
accepted by given DFA.
1) Let P be a regular language and Q be context-free language such that Q
⊆ P. (For example, let P be the language represented by the regular
expression p*q* and Q be {pnqn|n ∈ N}). Then which of the following is
ALWAYS regular?
(A) P ∩ Q
(B) P – Q
(C) ∑* – P
(D) ∑* – Q
Answer (C)
The expression ∑* – P represents complement of P which is a regular
language. Complement of Regular languages is also regular. Then a DFA that
accepts the complement of L, i.e. ∑* – L, can be obtained by swapping its
accepting states with its non-accepting states.

2) Consider the language L1,L2,L3 as given below.


L1={0p1q | p,q ∈ N}
L2={0p1q| p,q ∈ N and p=q}
L3={0p1q0r | p,q,r ∈N and p=q=r}
Which of the following statements is NOT TRUE?
(A) Push Down Automata (PDA) can be used to recognize L1 and L2
(B) L1 is a regular language
(C) All the three languages are context free
(D) Turing machine can be used to recognize all the three languages
Answer (C)
The language L3 is not context free. Refer this for more details.

3)Definition of a language L with alphabet {a} is given as following. L=


{ ank | k > 0, and n is a positive integer constant} What is the minimum
number of states needed in a DFA to recognize L?
(A) k+1
(B) n+1
(C) 2n+1
(D) 2k+1
Answer (B)
Note that n is a constant and k is any positive integer. For example, if n is given
as 3, then the DFA must be able to accept 3a, 6a, 9a, 12a, .. To build such a
DFA, we need 4 states.

1) S –> aSa| bSb| a| b ;The language generated by the above grammar


over the alphabet {a,b} is the set of
(A) All palindromes.
(B) All odd length palindromes.
(C) Strings that begin and end with the same symbol
(D) All even length palindromes.
Answer (B)
The strings accepted by language are {a, b, aaa, bbb, aba, bab, ..}. All of these
strings are odd length palindromes.

2) Which one of the following languages over the alphabet {0,1} is


described by the regular expression: (0+1)*0(0+1)*0(0+1)*?
(A) The set of all strings containing the substring 00.
(B) The set of all strings containing at most two 0’s.
(C) The set of all strings containing at least two 0’s.
(D) The set of all strings that begin and end with either 0 or 1.
Answer (C)
The regular expression has two 0’s surrounded by (0+1)* which means
accepted strings must have at least 2 0’s.

3) Which one of the following is FALSE?


(A) There is unique minimal DFA for every regular language
(B) Every NFA can be converted to an equivalent PDA.
(C) Complement of every context-free language is recursive.
(D) Every nondeterministic PDA can be converted to an equivalent deterministic
PDA.
Answer (D)
Deterministic PDA cannot handle languages or grammars with ambiguity, but
NDPDA can handle languages with ambiguity and any context-free grammar.
So every nondeterministic PDA can not be converted to an equivalent
deterministic PDA.

4) Match all items in Group 1 with correct options from those given in
Group 2.
Group 1 Group 2
P. Regular expression 1. Syntax analysis
Q. Pushdown automata 2. Code generation
R. Dataflow analysis 3. Lexical analysis
S. Register allocation 4. Code optimization

(A) P-4. Q-1, R-2, S-3


(B) P-3, Q-1, R-4, S-2
(C) P-3, Q-4, R-1, S-2
(D) P-2, Q-1, R-4, S-3
Answer (B)

5) . Let L = L1 ∩ L2, where L1 and L2 are languages as defined below:


L1 = {ambmcanbn | m, n >= 0 }
L2 = {aibjck | i, j, k >= 0 }
Then L is
(A) Not recursive
(B) Regular
(C) Context free but not regular
(D) Recursively enumerable but not context free.
Answer (C)
The language L1 accept strings {c, abc, abcab, aabbcab, aabbcaabb, …} and
L2 accept strings {a, b, c, ab, abc, aabc, aabbc, … }. Intersection of these two
languages is L1 ∩L2 = {akbkc | k >= 0} which is context free, but not regular.
1) Let L={w ∈ (0 + 1)*|w has even number of 1s}, i.e. L is the set of all bit
strings with even number of 1s. Which one of the regular expression
below represents L?
(A) (0*10*1)*
(B) 0*(10*10*)*
(C) 0*(10*1*)*0*
(D) 0*1(10*1)*10*
Answer (B)
Option (A) is incorrect because it cannot accept “110”
Option (C) is incorrect because it accept a string with single 1.
Option (D) is incorrect because it cannot accept 11101

2) Let L1 be a recursive language. Let L2 and L3 be languages that are


recursively enumerable but not recursive. Which of the following
statements is not necessarily true?
(A) L2 – L1 is recursively enumerable.
(B) L1 – L3 is recursively enumberable
(C) L2 ∩ L1 is recursively enumberable
(D) L2 ∪ L1 is recursively enumberable
Answer (B)
3) Consider the languages L1={0 i1j | i != j}, L2={0i1j | i = j}, L3 = {0i1j | i =
2j+1}, L4 = {0i1j | i != 2j}. Which one of the following statements is true?
(A) Only L2 is context free
(B) Only L2 and L3 are context free
(C) Only L1 and L2 are context free
(D) All are context free
Answer (D)
A Pushdown Automata can be built for all four languages.

4) Let w be any string of length n is {0,1}*. Let L be the set of all


substrings of w. What is the minimum number of states in a non-
deterministic finite automaton that accepts L?
(A) n-1
(B) n
(C) n+1
(D) 2n-1
Answer (C)
We need minimum n+1 states to build NFA that accepts all substrings of a
binary string. For example, following NFA accepts all substrings of “010” and it
has 4 states.
Regularexpreation

Consider the languages L1 =   and L2 = {a}. Which one of the following represents
L1 L2* U L1*

B
B
C
C
D
D
GATE CS 2013    Regular languages and finite automata    
Discuss it

Question 1 Explanation: 
L1 L2* U L1* Result of L1 L2* is  .{ } indicates an empty language.
Concatenation of   with any other language is  . It works as 0 in multiplication.
L1* =  * which is { }. Union of   and { } is { }
Question 2

WRONG

Consider the DFA given.   Which of the


following are FALSE?
1. Complement of L(A) is context-free.
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.
1 and 3 only
A
2 and 4 only

2 and 3 only
C
3 and 4 only

GATE CS 2013    Regular languages and finite automata    


Discuss it

Question 2 Explanation: 
1 is true. L(A) is regular, its complement would also be regular. A regular language is
also context free. 2 is true. 3 is false, the DFA can be minimized to two states. Where
the second state is final state and we reach second state after a 0. 4 is clearly false as
the DFA accepts a single 0.
Question 3

CORRECT

Given the language L = {ab, aa, baa}, which of the following strings are in L*?
1) abaabaaabaa
2) aaaabaaaa
3) baaaaabaaaab
4) baaaaabaa
1, 2 and 3
A
2, 3 and 4
B
1, 2 and 4

1, 3 and 4
D
Regular languages and finite automata    
Discuss it

Question 3 Explanation: 
See question 2 of http://www.geeksforgeeks.org/automata-theory-set-2/
Question 4

CORRECT

Given the language L = {ab, aa, baa}, which of the following strings are in L*?
1) abaabaaabaa
2) aaaabaaaa
3) baaaaabaaaab
4) baaaaabaa
1, 2 and 3
A
2, 3 and 4
B
1, 2 and 4

1, 3 and 4
D
Regular languages and finite automata    
Discuss it

Question 4 Explanation: 
See question 2 of http://www.geeksforgeeks.org/automata-theory-set-2/
Question 5

WRONG

Consider the set of strings on {0,1} in which, every substring of 3 symbols has at most
two zeros. For example, 001110 and 011001 are in the language, but 100010 is not. All
strings of length less than 3 are also in the language. A partially completed DFA that
accepts this language is shown

below.   The
missing arcs in the DFA
are 

A
A
B
B
C

GATE CS 2012    Regular languages and finite automata    


Discuss it

Question 5 Explanation: 
See http://www.geeksforgeeks.org/automata-theory-set-2/
Question 6

CORRECT

Definition of a language L with alphabet {a} is given as following.


L={ | k>0, and n is a positive integer constant}
What is the minimum number of states needed in DFA to recognize L?
k+1
A
n+1

2^(n+1)
C
2^(k+1)
D
GATE CS 2011    Regular languages and finite automata    
Discuss it

Question 6 Explanation: 
See Question 3 of http://www.geeksforgeeks.org/automata-theory-set-4/
Question 7

CORRECT

A deterministic finite automation (DFA)D with alphabet {a,b} is given

below   Which of the following


finite state machines is a valid minimal DFA which accepts the same language as

D?   

A
B
B
C
C
D
D
GATE CS 2011    Regular languages and finite automata    
Discuss it

Question 7 Explanation: 
Options (B) and (C) are invalid because they both accept ‘b’ as a string which is not
accepted by give DFA. (D) is invalid because it accepts "bba" which are not accepted by
given DFA.
Question 8

CORRECT

Let w be any string of length n is {0,1}*. Let L be the set of all substrings of w. What is
the minimum number of states in a non-deterministic finite automaton that accepts L?
n-1
A
n
B
n+1

2n-1
D
GATE CS 2010    Regular languages and finite automata    
Discuss it

Question 8 Explanation: 
We need minimum n+1 states to build NFA that accepts all substrings of a binary string.
For example, following NFA accepts all substrings of “010″ and it has 4

states. 
Question 9

CORRECT

Which one of the following languages over the alphabet {0,1} is described by the regular
expression: (0+1)*0(0+1)*0(0+1)*?
The set of all strings containing the substring 00.
A
The set of all strings containing at most two 0’s.
B
The set of all strings containing at least two 0’s.

The set of all strings that begin and end with either 0 or 1.
D
GATE-CS-2009    Regular languages and finite automata    
Discuss it

Question 9 Explanation: 
The regular expression has two 0′s surrounded by (0+1)* which means accepted strings
must have at least 2 0′s.
Question 10

CORRECT
Which one of the following is FALSE?
There is unique minimal DFA for every regular language
A
Every NFA can be converted to an equivalent PDA.
B
Complement of every context-free language is recursive.
C
Every nondeterministic PDA can be converted to an equivalent deterministic PDA.

GATE-CS-2009    Regular languages and finite automata    


Discuss it

Question 10 Explanation: 
Power of Deterministic PDA is not same as the power of Non-deterministic PDA.
Deterministic PDA cannot handle languages or grammars with ambiguity, but NDPDA
can handle languages with ambiguity and any context-free grammar. So every non-
deterministic PDA can not be converted to an equivalent deterministic PDA.
Which of the following statements is false?
Every NFA can be converted to an equivalent DFA
A
Every non-deterministic Turing machine can be converted to an equivalent

B deterministic Turing machine


Every regular language is also a context-free language
C
Every subset of a recursively enumerable set is recursive

Regular languages and finite automata    GATE CS 2008    


Discuss it

Question 11 Explanation: 

A language is recursively enumerable if there exists a Turing machine that accepts


every string of the language, and does not accept strings that are not in the language.
Strings that are not in the language may be rejected or may cause the Turing machine
to go into an infinite loop.
A recursive language can't go into an infinite loop, it has to clearly reject the string, but a
recursively enumerable language can go into an infinite loop.
So, every recursive language is also recursively enumerable. Thus, the statement
‘Every subset of a recursively enumerable set is recursive’ is false.
 
Thus, option (D) is the answer.
 
Please comment below if you find anything wrong in the above post.
Question 12

CORRECT

Given below are two finite state automata (→ indicates the start state and F indicates a
final state)Which of the following represents the product automaton

Z×Y? 
A

B
B
C
C
D
D
Regular languages and finite automata    GATE CS 2008    
Discuss it

Question 12 Explanation: 
All four states 11, 21, 22 , 12 are interpreted as P, Q, R and S. By looking at options we
can easily find out that →11 is P and 22(F) is R. Now say 12 is S and 21 is Q. Let’s
construct the transition table for ZxY.   So, the
answer should be (A) but in the row for S, it should be P and Q and not Q and P. Please
comment below if you find anything wrong in the above post.
Question 13

WRONG

Match the following NFAs with the regular expressions they correspond to
1. ϵ + 0(01*1 + 00) * 01*
2. ϵ + 0(10 *1 + 00) * 0
3. ϵ + 0(10 *1 + 10) *1
4. ϵ + 0(10 *1 + 10) *10 *

P - 2, Q - 1, R - 3, S - 4
P - 1, Q - 3, R - 2, S - 4
B
P - 1, Q - 2, R - 3, S - 4

P - 3, Q - 2, R - 1, S - 4
D
Regular languages and finite automata    GATE CS 2008    
Discuss it

Question 13 Explanation: 
Trick: Here we see in all the given figures then second state has a loop over the input
alphabets. In such cases we should resolve the loop at that state and transform the
NFA into a simpler one to get a regular expression for the NFA. For resolving the loop,
first reach the state where loop is to be resolved then draw all loops over that state and
all possible movements to move to the final state.
Figure P: (when loop resolved at middle state)
Loop at middle state is either by a 00 or a 01*1.

Hence the regular


expression: € + 0(00 +01*1)* 01*
Figure Q: (when loop resolved at middle state)
Loop at middle state is either by a 00 or a 10*1.

Hence the regular expression: € + 0(00


+10*1)* 0.
Figure R: (when loop resolved at middle state)
Loop at middle state is either by a 10 or a 10*1.

Hence the regular expression: € + 0(10


+10*1)* 1.
Figure S: (when loop resolved at middle state)
Loop at middle state is either by a 10 or a 10*1.

Hence the regular


expression: € + 0(10 +10*1)* 10*. The regular expressions matching with the above
gives suitable matching as P-1, Q-2, R-3, S-4 This explanation has been contributed
by Yashika Arora.
Question 14

WRONG

Which of the following are regular sets?

I and IV only

I and III only


B
I only

IV only
D
Regular languages and finite automata    GATE CS 2008    
Discuss it

Question 14 Explanation: 
  1.L = {a n b 2m |m, n ≥ 0} is a regular language of the form a ∗ (bb) ∗ . 2. L = {a n b m |
n = 2m} is not a regular language. This is a similar language as of {a n b n } which is
known to be not a regular language. 3. L = {a n b m |n notEqualTo m} is not regular
because there is no way to for finite automaton to remember n, number of as. 4. L =
{xcy|x, y ∈ {a, b} ∗ } is a regular language which is concatenation of {x|x ∈ a, b ∗ } on
itself with a alphabet c in between. Note: Regular languages are closed under
concatenation. Hence, correct answer would be (A) I and IV only.   This solution is
contributed by vineet purswani.
Question 15

WRONG

Which of the following is TRUE?


Every subset of a regular set is regular.
A
Every finite subset of a non-regular set is regular.

The union of two non-regular sets is not regular.

Infinite union of finite sets is regular.


D
Regular languages and finite automata    GATE-CS-2007    
Discuss it

Question 15 Explanation: 
Some points for Regular Sets:
 A set is always regular if it is finite.
 A set is always regular if a DFA/NFA can be drawn for it.
Option A: Every subset of a regular set is regular is False. For input alphabets a and b,
a*b* is regular. A DFA can be drawn for a*b* but a n b n for n≥0 which is a subset of
a*b* is not regular as we cannot define a DFA for it.
Option B: Every finite subset of a non-regular set is regular is True. Each and every set
which is finite can have a well-defined DFA for it so whether it is a subset of a regular
set or non-regular set it is always regular.
Option C: The union of two non-regular sets is not regular is False. For input alphabets
a and b, an bn for all n≥0 is non-regular as well as an bm for n≠m is also non- regular but
their union is a*b* which is regular.
Option D: TInfinite union of finite sets is regular is False. For input alphabets a and b
sets {ab}, {aabb}, {aaabbb}…….. are regular but their union {ab} U {aabb} U {aaabbb} U
…………………….. gives {a n b n for n>0} which is not regular.

This solution is contributed by Yashika Arora.


Question 16

CORRECT

A minimum state deterministic finite automaton accepting the language L={w | w ε {0,1}
*, number of 0s and 1s in w are divisible by 3 and 5, respectively} has
15 states

11 states
B
10 states
C
9 states
D
Regular languages and finite automata    GATE-CS-2007    
Discuss it

Question 16 Explanation: 
  Here a string w of 0's and 1's should have the property that, the no of 0's in the string
w should be divisible by 3 ( N(0) % 3 =0 ), and the number of 1's the string w should be
divisible by 5 (N(1) % 5 =0). Having said that, the Language will contain the strings such
as : { ε , 000, 11111, 00011111, 00111101 , 11111000, 10101011 ,
00000011111,....and so on } So, strings accepted by the automaton have to be of length
0, 3, 5, 8, 11, 13, 14, 16....and so on, i.e. equation for length will be 3x + 5y (where
x,y>=0 ) Modulo 3 gives remainder as ( 0, 1, 2 ) , and Modulo 5 gives remainder as ( 0,
1, 2, 3, 4 ).  Hence 3 * 5 sates, i.e. there will be 15 states in the automaton to represent
this. Please comment below if you find anything wrong in the above post.
Question 17

WRONG
Which of the following languages is

regular? 
A

B
B
C

D
D
Regular languages and finite automata    GATE-CS-2007    
Discuss it

Question 17 Explanation: 

(C) Strings which are the part of this language are either 0w0 or 1w1 where w is any
string in {0, 1}* . Thus, language given in option (C) is regular.
 
All other languages accept strings which have a palindrome as their substring.
(A) Strings intersect with 0*110* .
(B) Strings intersect with 0*110*1 .
(D) Strings intersect with 10*110* .
According to pumping lemma, languages given option (A), (B) and (D) are irregular.
 
Thus, option (C) is the answer.
 
Please comment below if you find anything wrong in the above post.
Question 18

WRONG

Consider the following Finite State Automaton. The language accepted by this
automaton is given by the regular
expression   

  
A
A
B

D
D
Regular languages and finite automata    GATE-CS-2007    
Discuss it

Question 18 Explanation: 
In this case, we would at least have to reach q1 so that our string gets accepted. So, b*
a is the smallest accepted string. Now, at q1, any string with any number of a's and b's
would be accepted. So, we append (a + b)* to the smallest accepted string.
 
Thus, the string accepted by the FSA is b* a (a + b)*.
 
Thus, C is the correct choice.
 
Please comment below if you find anything wrong in the above post.
Question 19

WRONG

Consider the automata given in previous question. The minimum state automaton
equivalent to the above FSA has the following number of states
1
A
2

3
C
4

Regular languages and finite automata    GATE-CS-2007    


Discuss it

Question 19 Explanation: 

Following is equivalent FSA with 2 states. 


Question 20

WRONG

Which one of the following is


TRUE? 

A
A
B

D
D
Regular languages and finite automata    GATE-CS-2014-(Set-1)    
Discuss it

Question 20 Explanation: 
(A) L = {a n b n |n >= 0} is not regular because there does not exists a finite automaton
that can derive this grammar. Intuitively, finite automaton has finite memory, hence it
can’t track number of as. It is a standard CFL though. (B) L = {a n b n |n is prime} is
again not regular because there is no way to remember/check if current n is prime or
not. Hence, no finite automaton exists to derive this grammar, thus it is not
regular. (C) L = {w|w has 3k+1 bs} is a regular language because k is a fixed constant
and we can easily emulate L as a ∗ ba ∗ .....ba ∗ such that there are exactly 3k + 1 bs
and a ∗ s surrounding each b in the
grammar. 

 
(D) L = {ww| w ∈ Σ ∗ } is again not a regular grammar, infact it is not even a CFG. There
is no way to remember and derive double word using finite automaton. Hence, corr
Question 21

WRONG

{q0, q1, q2}


{q0, q1}

{q0, q1, q2, q3}


C
{q3}
D
Regular languages and finite automata    GATE-CS-2014-(Set-1)    
Discuss it

Question 21 Explanation: 

 
So, q0, q1 and q2 are reachable states for the input string 0011, but q3 is not. So,
option (A) is answer.
Question 22

WRONG

Which of the regular expressions given below represent the following

DFA? 
I) 0*1(1+00*1)*
II) 0*1*1+11*0*1
III) (0+1)*1
I and II only

I and III only

II and III only


C
I, II, and III
D
Regular languages and finite automata    GATE-CS-2014-(Set-1)    
Discuss it

Question 22 Explanation: 
I) 0*1(1+00*1)*
II) 0*1*1+11*0*1
III) (0+1)*1

(I) and (III) represent DFA.

(II) doesn't represent as the DFA accepts strings like 11011,


but the regular expression doesn't accept.

Question 23

CORRECT

 Which one of the


following is CORRECT?
Only (I)

Only (II)
B
Both (I) and (II)
C
Neither (I) nor (II)
D
Regular languages and finite automata    GATE-CS-2014-(Set-2)    
Discuss it

Question 23 Explanation: 
L1.L2 is definitely regular, since regular languages are closed under concatenation. But
L1.L2 = { anbn | n ≥ 0 } is not correct. Because both variable are independent of each
other. L1.L2 = { anbm | n ≥ 0 , m ≥ 0 } is possible. Therefore, only statement (i) is TRUE.
Question 24

CORRECT

Let L1 = {w ∈ {0,1}∗ | w has at least as many occurrences


of (110)’s as (011)’s}.

Let L2 = { ∈ {0,1}∗ | w has at least as many occurrences


of (000)’s as (111)’s}.
Which one of the following is TRUE?
L1 is regular but not L2

L2 is regular but not L!


B
Both L2 and L1 are regular
C
Neither L1 nor L2 are regular
D
Regular languages and finite automata    GATE-CS-2014-(Set-2)    
Discuss it

Question 24 Explanation: 
L1 is regular let us consider the string 011011011011 In this string, number of
occurrences of 011 are 4 but when we see here 110 is also occurred and the number of
occurrence of 110 is 3. Note that if i add a 0 at the last of string we can have same
number of occurrences of 011 and 110 so this string is accepted. We can say if the
string is ending with 011 so by appending a 0 we can make 110 also. Now string2:
110110110110 in this number of occurrences of 110 is 4 and 011 is 3 which already
satisfy the condition So we can observe here that whenever 110 will be there string will
be accepted So with this idea we can build an automata for this. Therefore, it is regular.
Question 25

WRONG
The length of the shortest string NOT in the language (over Σ = {a, b}) of the following
regular expression is ______________.
a*b*(ba)*a*
2

4
C
5
D
Regular languages and finite automata    GATE-CS-2014-(Set-3)    
Discuss it

Question 25 Explanation: 
All the strings that can be generated till length-2 are definitely present in this language.
Now, let's look at the strings of length-3; {aaa, aab, aba, abb, baa, bab, bba, bbb} .
String "bab" cannot be generated from given language. so, the string "bab" is the
shortest string not acceptable by given regular expression.
Question 26

CORRECT

If s is a string over (0 + 1)* then let n0(s) denote the number of 0’s in s and n1(s) the
number of 1’s in s. Which one of the following languages is not

regular?  7" />


A
A
B
B
C

D
D
Regular languages and finite automata    GATE-CS-2006    
Discuss it
Question 26 Explanation: 
Languages in option (A) And (D) are finite so both the options are eliminated. For option
A: There are finite no. of 3 digit prime numbers. There exists a FA for every finite set.
Hence FA is possible. For option D: Possible remainders for 7 is 0 to 6, and for 5 its 0 to
4. Using 35 states, FA can be made. For option B: We can have 6 states (including 1
reject state) state 1: difference is 0 state 2: difference is 1 (more 1s) state 3: difference
is 1 (more 0s) state 4: difference is 2 (more 1s) state 5: difference is 2 (more 0s) state 6:
reject state for difference >= 3 Suppose the string is 000101 Scan 0 -> state 3 Scan 0 ->
state 5 Scan 0 -> reject (since diff. is 3 now) Similarly if we try for string: 010100, this
will be accepted.
Question 27

CORRECT

Consider the regular language L = (111 + 11111)*. The minimum number of states in
any DFA accepting this languages is:
3
A
5
B
8
C
9

Regular languages and finite automata    GATE-CS-2006    


Discuss it

Question 27 Explanation: 

The finite state automata is :   Explanation: It


is given that language L = (111 + 11111)* Strings , that belongs in the language are L =
{null , 111 , 11111, 111111 , 11111111 , 111111111 , 1111111111 , ……. form string
length 8 , (number of 1’s) , now we can can generate any length of string from length 3
and 5 (i.e. length 8 ,length 9, length 10 , length 11 ,…etc)} L = {null , 111 , 11111,
111111 , 11111111 , 111111111* } Strings in length , that belongs in the language L =
{0 ,3, 5, 6, 8, 9, 10, 11, …} So, there are 5 states that are final states and 4 states that
are non-final states Therefore total number of states are 9 states . hence option D is
true. This explanation has been contributed by Namita Singh.
Question 28

WRONG

Consider the machine M:   The


language recognized by M is :
{w ∈ {a, b}* / every a in w is followed by exactly two b's}
A
{w ∈ {a, b}* every a in w is followed by at least two b’}

{w ∈ {a, b}* w contains the substring 'abb'}


C
{w ∈ {a, b}* w does not contain 'aa' as a substring}

Regular languages and finite automata    GATE-CS-2005    


Discuss it

Question 28 Explanation: 
 
Here w ∈ {a, b}* means w can be any string from the set of {a, b}* and {a, b}* is set of all strings composed
of a and b (any string of a and b that you can think of) like null, a, b, aaa, abbaaa, bbbbb, aaaaa,
aaaabbbbaabbababab etc.
These type of questions are frequently asked in GATE, where it is asked to choose best fit language among
the options. To slove the question like this, there is a better way, we try to eliminate wrong options by
choosing testing strings intelligently until we are left with one right option.As given in question, let’s we try to
eliminate option (A), it recognizes only those string (composed of a and b) in which every a in w is
followed by exactly two b’s , so if we take string abbb(three b’s), then it is accepted by machine , so this
options is wrong. Now we try to eliminate option (C), it recognizes only those strings(composed of a and b)
in which w contains the substring ‘abb’, so if we take string abbaa (has substring abb), then it is not
accepted by machine, so this options is also wrong. Now we try to eliminate option (D), it recognizes only
those string(composed of a and b) in which w does not contains ‘aa’ as a substring , so if we take string
abbaba(‘aa’ not as a substring), then it is not accepted by machine ,so this options is also wrong. Only
option with which we are left, is option (b) in which every a in w is followed by at least two b’ ,is correct.So
answer is option (B).
This solution is contributed by Nirmal Bharadwaj.
Question 29

WRONG

Let Nf and Np denote the classes of languages accepted by non-deterministic finite


automata and non-deterministic push-down automata, respectively. Let Df and Dp
denote the classes of languages accepted by deterministic finite automata and
deterministic push-down automata, respectively. Which one of the following is TRUE?
Df ⊂ Nf and Dp ⊂ Np
A
Df ⊂ Nf and Dp = Np
B
Df = Nf and Dp = Np

Df = Nf and Dp ⊂ Np

Regular languages and finite automata    GATE-CS-2005    


Discuss it

Question 29 Explanation: 
Deterministic pushdown automata can recognize all deterministic context-free
languages while nondeterministic ones can recognize all context-free languages. Mainly
the former are used in parser design
(Source: http://en.wikipedia.org/wiki/Pushdown_automaton ). Deterministic context-free
languages (DCFL) are a proper subset of context-free languages. Non-deterministic
finite automata and Deterministic finite automata, both accept same set of languages as
NFAs can be translated to equivalent DFAs using the subset construction algorithm.
Question 30

WRONG

The following diagram represents a finite state machine which takes as input a binary

number from the least significant bit.   Which one of the


following is TRUE?
It computes 1's complement of the input number
It computes 2's complement of the input number

It increments the input number


C
It decrements the input number
D
Regular languages and finite automata    GATE-CS-2005    
Discuss it

Question 30 Explanation: 
The given finite state machine takes a binary number from LSB as input.
The given FSM remains unchanged till first ‘1’ . After that it takes 1’s complement of rest
of the input string.
We assume the input string to be ‘110010’ . Thus, according to the FSM, output is
‘001110’ .
2’s complement of ‘110010’ = 1’s complement of ‘110010’ + 1 = 001101 + 1 = 001110
Thus, the FSM computes 2’s complement of the input string.
 
Hence, option (B) is correct.
 
Please comment below if you find anything wrong in the above post.
Question 31

WRONG

The following finite state machine accepts all those binary strings in which the number

of 1's and 0's are respectively. 


divisible by 3 and 2

odd and even


B
even and odd
divisible by 2 and 3
D
Regular languages and finite automata    GATE-CS-2004    
Discuss it

Question 31 Explanation: 
 
Option (B) is eliminated because string 100 contains odd number of 1s and even number of 0s but is not
accepted by the DFA. Option(C) is eliminated because string 011 contains even number of 1s and odd
number of 0s but is not accepted by the DFA. Option (D) is eliminated because string 11000 has number of
1s divisible by 2 and number of 0s divisible by 3 but still not accepted by the DFA. Option (A) accepts all
strings with number of 1s divisible by 3 and number of 0s divisible by 2.
Extra note: In any case where (no of 1s) MOD N= some integer k and (no of 0s) MOD M= some integer q
the number of states in the DFA will be equal to N*M. (The product could be taken for all input alphabets.)
E.g.: if we say no. of ones is even and no. of 0s is odd (we check if (no. of 1s) MOD 2=0 and (no. of 0s)
MOD 2=0) so no. of states in the DFA=2*2=4. Hence option (B) and (C) can directly be eliminated as the
DFA has 6 states and we can look only at the remaining two options.
This solution is contributed by Yashika Arora .
Question 32

CORRECT

The regular expression 0*(10*)* denotes the same set as


(1*0)*1*

0 + (0 + 10)*
B
(0 + 1)* 10(0 + 1)*
C
none of these
D
Regular languages and finite automata    GATE-CS-2003    
Discuss it

Question 32 Explanation: 
There is property of regular expression (a+b)* = (a*b*)* = (a*+b*)* = (a*+b)* = a*(ba*)*=
(b*a)*b*. (1*0)*1* can generate all strings that generated by given regular expression
0*(10*)*. So, option (A) is correct.
Question 33

WRONG
Consider the following deterministic finite state automaton

M.   Let S denote the set of seven bit binary


strings in which the first, the fourth, and the last bits are 1. The number of strings in S
that are accepted by M is
1

5
B
7

8
D
Regular languages and finite automata    GATE-CS-2003    
Discuss it

Question 33 Explanation: 
Given a language of 7 bit strings where 1st, 4th and 7th bits are 1. The following are 7
strings of language that can be accepted by DFA. 1001001 1001011 1001101 1001111
1101001 1111001 1011001
Question 34

WRONG

Consider the NFA M shown below.   Let the language


accepted by M be L. Let L1 be the language accepted by the NFA M1, obtained by
changing the accepting state of M to a non-accepting state and by changing the non-
accepting state of M to accepting states. Which of the following statements is true ?
L1 = {0, 1}* - L
L1 = {0, 1}*

L1 ⊆ L
C
L1 = L
D
Regular languages and finite automata    GATE-CS-2003    
Discuss it

Question 34 Explanation: 
In case of a Deterministic Finite Automata (DFA) when we change
the accepting states into non-accepting states and non-accepting
states into accepting states, the new DFA obtained accepts the complement
of the language accepted by the initial DFA. It is because we have one
single movement for a particular input alphabet from one state so the
strings
accepted by the transformed DFA will be all those which are not accepted
by
the actual DFA.
But it is not the case with the NFA’s (Non-Deterministic Finite
Automata). In case of NFA we need to have a check on the language
accepted by the
NFA. The NFA obtained by changing the accepting states to non-accepting
states and
non-accepting states to accepting states is as follows:-
Here we can see that as
i. The initial state is an accepting state hence null string is always
accepted by
the NFA.
ii. There is a movement from state 1 to state 2 on both {0, 1} input
alphabets and
further any number of 1’s and 0’s or even none in the string lets
the string be
at an accepting state(state 2).

Hence the language accepted by the NFA can be any string with any
combination of 0’s
and 1’s including a null string i.e. {null, 0, 1, 00, 01, 10, 11,……………..}
so L1= {0, 1}*.
This Explanation has been contributed by Yashika Arora.
Question 35

WRONG

The Finite state machine described by the following state diagram with A as starting
state, where an arc label is x / y and x stands for 1-bit input and y stands for 2- bit

output 
Outputs the sum of the present and the previous bits of the input.

Outputs 01 whenever the input sequence contains 11.

Outputs 00 whenever the input sequence contains 10.


C
None of these
D
Regular languages and finite automata    GATE-CS-2002    
Discuss it

Question 35 Explanation: 

We assume the input string to be 1101.


1. (A, 1) --> (B, 01) Here, previous input bit + present input bit = 0 + 1 = 01 = output
2. (B, 1) --> (C, 10) Here, previous input bit + present input bit = 1 + 1 = 10 = output
3. (C, 0) --> (A, 01) Here, previous input bit + present input bit = 1 + 0 = 01 = output
4. (A, 1) --> (B, 01) Here, previous input bit + present input bit = 0 + 1 = 01 = output
 
Thus, option (A) is correct.
 
Please comment below if you find anything wrong in the above post.
Question 36

WRONG

The smallest finite automation which accepts the language {x | length of x is divisible by
3} has :
2 states

3 states

4 states
C
5 states
D
Regular languages and finite automata    GATE-CS-2002    
Discuss it

Question 36 Explanation: 

 
 Thus, we require 3 states.
 
So, B is the correct choice.
 
Please comment below if you find anything wrong in the above post.
Question 37

WRONG

Consider the following two

statements: 
Only S1 is correct

Only S2 is correct
B
Both S1 and S2 are correct
C
None of S1 and S2 is correct

Regular languages and finite automata    GATE-CS-2001    


Discuss it

Question 37 Explanation: 
We can easily build a DFA for S1. All we need to check is whether input string has even
number of 0's. Therefore S1 is regular. We can't make a DFA for S2. For S2, we need a
stack. Therefore S2 is not regular.
Question 38

WRONG

Given an arbitary non-deterministic finite automaton (NFA) with N states, the maximum
number of states in an equivalent minimized DFA is at least
N2
A
2N

2N

N!
D
Regular languages and finite automata    GATE-CS-2001    
Discuss it

Question 38 Explanation: 
Refer http://en.wikipedia.org/wiki/Powerset_construction
Question 39

WRONG

Consider a DFA over ∑ = {a, b} accepting all strings which have number of a’s divisible
by 6 and number of b’s divisible by 8. What is the minimum number of states that the
DFA will have?
8

14
B
15
C
48

Regular languages and finite automata    GATE-CS-2001    


Discuss it

Question 39 Explanation: 

We construct a DFA for strings divisible by 6. It requires minimum 6 states as length of


string mod 6 = 0, 1, 2, 3, 4, 5
We construct a DFA for strings divisible by 8. It requires minimum 8 states as length of
string mod 8 = 0, 1, 2, 3, 4, 5, 6, 7
If first DFA is minimum and second DFA is also minimum then after merging both DFAs
resultant DFA will also be minimum. Such DFA is called as compound automata.
So, minimum states in the resultant DFA = 6 * 8 = 48
 
Thus, option (D) is the answer.
 
Please comment below if you find anything wrong in the above post.
Question 40

WRONG

Consider the following languages   

   
Which of the languages are regular?
Only L1 and L2

Only L2, L3 and L4


B
Only L3 and L4
C
Only L3

Regular languages and finite automata    GATE-CS-2001    


Discuss it

Question 40 Explanation: 
A language is known as regular language if there exists a finite automaton (no matter
whether it is deterministic or non-deterministic) which recognizes it. So if for a given
language, we can come up with an finite automaton, we can say that the language is
regular. But sometimes, it is not quite obvious to design an automaton corresponding to
a given language but it surely exists. In that case, we should not start thinking that the
given language is not regular. We should use pumping lemma to decide whether the
given language is regular or not. According to pumping lemma, “Suppose L is a
regular language, then there exists a l ≥ 1 such that for all string s ∈ L, where |s| ≥ l, we
can always split s (there exists at least one such splitting) in such a way that s can be
written as xyz with |xy| ≤ l and y ≠ ε and for all i ≥ 0 , xy iz ∈ L”. l is known as pumping
length. Let’s rephrase the given Lemma for non regular languages. Suppose L is a
language, if for all l ≥ 1 there exist a string s ∈ L with |s| ≥ l such that for all splitting
(there doesn’t exists a single splitting which doesn’t follow this rule) of s in form of xyz
such that |xy| ≥ l and y ≠ ε , there exists an i≥ 0 such that xy iz ∉ L, then L is not regular.
Notice that here we stress on finding such s if we want to prove that a language is not
regular. Choice of the Questions: (a) In choice 1, Lets first consider w being of length
n and containing only a. In this case the language represents a nan. The length of the
string represented by language should be Even. Consider l = n, then xyz = a nan with xy =
an. lets assume y = a, then consider the membership of xy iz with i = 0. This will simply
be of odd length which doesn’t belongs to L. So L is not regular. To discuss it in more
detail, let’s consider another example. Suppose w = a pb, then string formed by L will be
apbapb which is of length 2p + 2. Assume l = p, then xy = a p. suppose y = a, then
consider the membership of xyiz with i = 0. This certainly doesn’t belongs to L. So L is
not regular. (b) In choice 2, The first example will work as above. In the second
example, the string will be apbbap, and there will be no changes in process for proving it
to be non regular. (c) In choice 3, Assuming that we are considering integer from 0 and
02∗n results in empty string, Which is also accepted, We can simply construct a DFA as
given below. It simply accepts a string if it is either empty or contain even number of

zeros. So the language is regular. (d) In


choice 4, We can simply assume that the pumping length l =i 2/2. Now consider the xy =
0l with y = 0, Now if we check the membership of xy2z, we can find that this will
represent 0i^2+1, and corresponding to which there exists no j such that j 2 = i2 + 1 where i
and j are integer except j = 1 and i = 0. But since i can’t be zero. In Short, using
pumping lemma, we can generate 0i^2+1 as well as 0i^2-1, which won’t be available in L.
So L is not regular. This explanation has been contributed by Durgesh Pandey.
Question 41

CORRECT

Let S and T be language over Σ = {a,b} represented by the regular expressions (a+b*)*
and (a+b)*, respectively. Which of the following is true?
S⊂T
A
T⊂S
B
S=T

S∩T=φ
D
Regular languages and finite automata    GATE-CS-2000    
Discuss it
Question 41 Explanation: 
Both have same output because if we draw DFA of S which is (a+b*)*, at final state it is
just repeating.
Question 42

WRONG

Let L denotes the language generated by the grammar S -> 0S0/00. Which of the
following is true?
L = 0+
A
L is regular but not 0+

L is context free but not regular

L is not context free


D
Regular languages and finite automata    GATE-CS-2000    
Discuss it

Question 42 Explanation: 
Option A : L is not 0+ , because 0+ will contain any arbitrary string over alphabet 0 with
any no of 0's ( except empty string ), for ex: {0, 00, 000,00000}, but L will only have the
strings as { 00, 0000, 000000,...}, i.e only even no of  0's ( excluding empty string}.
Option D : L is a Context Free Language, because the Grammar G which generates
the language L is Context Free Grammar. A Grammar G is CFG if all of its productions
are of the form A->α, where A is a single non-terminal and α belongs to (V∪ T)* , i.e  α
can be a string of terminals and/or Non-terminals. (V represents a non-terminal and T
represents a terminal)   Option C : L is a Regular Language, Because we are able to
write a regular expression for it ( and also able to make a Finite Automaton), which is
(00)+.     Option B :  Hence This option is
Correct, because L is Regular but not 0+, as we proved above.
Question 43

WRONG

What can be said about a regular language L over {a} whose minimal finite state
automaton has two states?
L must be {an| n is odd}
A
L must be {a | n is even}
B
n

L must be {an| ³ O}

Either L must be {an | n is odd}, or L must be {an | n is even}

Regular languages and finite automata    GATE-CS-2000    


Discuss it

Question 43 Explanation: 
There are two states. When first state is final, it accepts even no. of a's. When second
state is final, it accepts odd no. of a's.
Question 44

WRONG
Consider the following Deterministic Finite

Automata   Which of the following is true?


It only accepts strings with prefix as "aababb"

It only accepts strings with substring as "aababb"

It only accepts strings with suffix as "aababb"


C
None of the above
D
Regular languages and finite automata    GATE-CS-2015 (Mock Test)    
Discuss it

Question 44 Explanation: 
  To reach the accepting state, any string will have to go through edges having aababb
as labels in order. Though it might not be a continuous substring, but it sure will be a
substring. There might be some cases where same substring always exists as a prefix
or suffix for some DFA, but in this situation we don’t have to consider those cases, given
this question has single choice answer. − > O − a− > O − a− > O − b− > O − a− > O −
b− > O − b− > O Hence, correct answer should be (B). This solution is contributed
by vineet purswani.
Question 45

WRONG

How many minimum states are required in a DFA to find whether a given binary string
has odd number of 0's or not, there can be any number of 1's.
1
A
2

4
D
Regular languages and finite automata    GATE-CS-2015 (Mock Test)    
Discuss it
Question 45 Explanation: 

Question 46

CORRECT

Consider the DFAs M and N given above. The number of states in a minimal DFA that
accepts the language L(M) ∩ L(N) is

__________. 
0
A
1

2
C
3
D
Regular languages and finite automata    GATE-CS-2015 (Set 1)    
Discuss it

Question 46 Explanation: 
In DFA M: all strings must end with 'a'. In DFA N: all strings must end with 'b'. So the
intersection is empty. For an empty language, only one state is required in DFA. The
state is non-accepting and remains on itself for all characters of

alphabet. 
Question 47

WRONG

Consider alphabet ∑ = {0, 1}, the null/empty string λ and the sets of strings X 0, X1 and
X2 generated by the corresponding non-terminals of a regular grammar. X 0, X1 and
X2 are related as follows:
X0 = 1 X1
X1 = 0 X1 + 1 X2
X2 = 0 X1 + {λ}
Which one of the following choices precisely represents the strings in X 0?
10 (0* + (10)*)1

10 (0* + (10)*)*1
B
1(0* + 10)*1

10 (0 + 10)*1 + 110 (0 + 10)*1


D
Regular languages and finite automata    GATE-CS-2015 (Set 2)    
Discuss it

Question 47 Explanation: 
The smallest possible string by given grammar is "11".
X0 = 1X1
= 11X2 [Replacing X1 with 1X2]
= 11 [Replacing X2 with λ]

The string "11" is only possible with option (C).


Question 48

WRONG

Which of the following languages is/are regular?


L1: {wxwR ⎪ w, x ∈ {a, b}* and ⎪w⎪, ⎪x⎪ >0} wR is the reverse of string w
L2: {anbm ⎪m ≠ n and m, n≥0
L3: {apbqcr ⎪ p, q, r ≥ 0}
L1 and L3 only

L2 only
B
L2 and L3 only
C
L3 only

Regular languages and finite automata    GATE-CS-2015 (Set 2)    


Discuss it

Question 48 Explanation: 
L3 is simple to guess, it is regular.
Below is DFA for L1.

L1 is interesting. The important thing to note


about L1 is length of x is greater than 0, i.e.,
|x| > 0.
So any string than starts and ends with same character
is acceptable by language and remaining string becomes w.
Below is DFA for L1.
Question 49

WRONG

The number of states in the minimal deterministic finite automaton corresponding to the
regular expression (0 + 1)*(10) is ____________
2

4
C
5
D
Regular languages and finite automata    GATE-CS-2015 (Set 2)    
Discuss it

Question 49 Explanation: 
Below is NFA for the given regular expression (0 +

1)*(10) 
Question 50

WRONG

Let T be the language represented by the regular expression Σ∗0011Σ∗ where Σ = {0,
1}. What is the minimum number of states in a DFA that recognizes L' (complement of
L)?
4

6
C
8
D
Regular languages and finite automata    
Discuss it

Question 50 Explanation: 
DFA for language represented by the regular expression Σ∗0011Σ∗ where Σ = {0, 1} is
as following below:

Th
e complement of above DFA will have same number of states but there will be non-final
states to final states and final state to non-final state. So, option (B) is correct.
Question 51

WRONG

Which one of the following regular expressions is NOT equivalent to the regular
expression (a + b + c) *?
(a* + b* + c*)*

(a*b*c*)*
B
((ab)* + c*)*

(a*b* + c*)*
D
Regular languages and finite automata    GATE-IT-2004    
Discuss it

Question 51 Explanation: 
C- (ab)* + c*)* will always give strings with "ab" together.Whereas (a+b+c)* would
generate language where a,b,c may not be always together. A,B,D may generate same
language as (a+b+c)*   So, Answer is (C)
Question 52

WRONG

Which one of the following strings is not a member of L (M)?

 
aaa
A
aabab

baaba

bab
D
Regular languages and finite automata    GATE-IT-2004    
Discuss it

Question 52 Explanation: 
  Basics of PDA A push down automata or a PDA is essentially a NFA with a stack and
its transition function also depends on the symbol at the stack top. Formally, a PDA is a
6-tuple (Q, Σ, Γ, δ, q0, F) with Q being set of all possible states, Σ is the set of all
possible input, Γ is the set of all possible stack symbol, δ : Q × Σ× Γ→ Q × Γ is the
transition function, q0 is the initial state, and F ⊆ Q is the set of final state. Some times,
PDA is also known to be of 7 tuples when we considers the initial stack symbol z0 as an
additional member in the above 6 tuples. Note that there should exists a transition
function for a given input otherwise there won’t be any possible move. The PDA can be
of two types: Empty stack accepting PDA and Final state PDA. Empty stack accepting
PDAs are the PDAs for which a given input is accepted if on a given input string, when
the input exhausts, the stack should be empty. Similarly, a Final state accepting PDA is
a PDA for which a given input is accepted if on a given input string, when the input
exhausts, thePDA should be in one of the final states. A Non-deterministic PDA or
NPDA is a PDA in which, for a given input, multiple output is possible. i.e. The
Transition function δ maps a given input from Q × Σ× Γto a finite set of Q × Γ. For the
given question, since there is a more than one output corresponding to a given input
for transition function, we will consider a NPDA for the execution of the input and we will
halt our execution for a corresponding branch if there is no move possible for a given
input and We assume that if the machine halts at one of the final state and input is
exhausted, we accept the string otherwise we reject it. Notice, the Given PDA is final
state accepting PDA and not the empty stack accepting PDA. Choice of the
Questions:   We will assume the initial stack symbol is ε, and   • In choice 1, The
execution will be as follow: (s, a, ) → (s, a) or (f, ε). Let’s first consider, (s, a) as output
and execute the remaining input. (s,a, a) → No valid Move. halt this branch and not in
the final state, so not accepted. Now consider (f, ε) as output. (f, a, ε) → No Valid
Move. halt this branch Notice that the PDA is in one of the final state, But the input
string is not exhausted, So this should not be accepted by the PDA.   • In choice 2, The
Execution will start as of choice 1 and will halt at character 2 as no possible move. This
option is also not accepted in same way as of the first option. 3   • In choice 3, The
execution will be as follow: (s, b, ε) → (s, a). (s, a, a) → No Possible move. halt this
branch. Since halted before reaching to any final state so this option is not accepted.  
• In choice 4, This option is also not accepted as the PDA will halt at second character
as it halted in previous option. This option is also not accepted.   Assuming that if the
PDA halts on a input due to no possible move and if the current state is one of the final
state but the input is not exhausted, PDA will reject that string, For Question 2, Every
answer is true i.e. None of the given for string belongs to the given PDA’s language.
Again, Assuming that if the PDA halts on a input due to no possible move and if the
current state is one of the final state but the input is not exhausted, the PDA will keep on
consuming the input string until the end of string comes, string in option (A) and option
(B) will be accepted by the language of this PDA. while option (C) and option (D) still
won’t get accepted as by the end of the string, the PDA won’t be in final state. So
keeping this assumption in mind, option (C) and option (D) both will be true for this
question. This explanation is contributed by Durgesh Pandey.
Question 53

CORRECT

Let L be a regular language and M be a context-free language, both over the alphabet
Σ. Let Lc and Mc denote the complements of L and M respectively. Which of the
following statements about the language Lc∪ Mc is TRUE
It is necessarily regular but not necessarily context-free
A
It is necessarily context-free.
B
It is necessarily non-regular.
C
None of the above

Regular languages and finite automata    Gate IT 2005    


Discuss it

Question 53 Explanation: 
  Proposition: L is a regular language M is a context free language Derivation: L_c 
union M_c = complement{L intersection M} Now, L intersection M is a CFL according to
closure laws of CFLs, i.e. intersection of a CFL with RL is always a CFL. But,
complement{L intersection M} might not be a CFL because complement over CFL
doesn't guarantee a CFL. It can even be a RL or it might even lie outside the CFL circle.
It will be a context-sensitive language certainly, but nothing else can be said about it.
Conclusion: Considering the above derivation, none of the statements are true. Hence
correct answer would be (D) None of the above. Related
article : http://quiz.geeksforgeeks.org/theory-of-computation-closure-properties-of-
context-free-languages/ This solution is contributed by Vineet Purswani.
Question 54

WRONG

Which of the following statements is TRUE about the regular expression 01*0?
It represents a finite set of finite strings.
A
It represents an infinite set of finite strings.

It represents a finite set of infinite strings.


C
It represents an infinite set of infinite strings

Regular languages and finite automata    Gate IT 2005    


Discuss it

Question 54 Explanation: 
First of all, A string can never be infinite because String is a finite sequence of symbols
over Σ So option (c) and (d) are eliminated. And because of star(*) it can generate
infinite set. So Option (B) is CORRECT.   This solution is contributed
by Abhishek Agrawal.
Question 55
WRONG

The language {0n 1n 2n | 1 ≤ n ≤ 106} is  


regular

context-free but not regular.


B
context-free but its complement is not context-free.
C
not context-free

Regular languages and finite automata    Gate IT 2005    


Discuss it

Question 55 Explanation: 

The value of ‘n’ is finite. So, only finite number of strings can be part of given language.
Therefore, we can construct a finite state automata for this language.
 
Thus, option (A) is correct.
 
Please comment below if you find anything wrong in the above post.
Question 56

WRONG
Consider the non-deterministic finite automaton (NFA) shown in the figure.

State X is the starting state of the automaton. Let the language accepted by the NFA
with Y as the only accepting state be L1. Similarly, let the language accepted by the
NFA with Z as the only accepting state be L2. Which of the following statements about
L1 and L2 is TRUE? Correction in Question: There is an edge from Z->Y labeled 0
and another edge from Y->Z labeled 1 - in place of double arrowed and no arrowed
edges.
L1 = L2

L1 ⊂ L2

L2 ⊂ L1
C
None of the above
D
Regular languages and finite automata    Gate IT 2005    
Discuss it

Question 56 Explanation: 
According to Arden’s Theorem, For y as final state:
Y = X0 + Y0 + Z1
For z as final state:
Z = X0 + Y0 + Z1
Hence,
L(Y) = L(Z)
So, option (A) is correct.
Question 57

WRONG

A language L satisfies the Pumping Lemma for regular languages, and also the
Pumping Lemma for context-free languages. Which of the following statements about L
is TRUE?  
L is necessarily a regular language.

L is necessarily a context-free language, but not necessarily a regular language


B
L is necessarily a non-regular language
C
None of the above

Regular languages and finite automata    Gate IT 2005    


Discuss it

Question 57 Explanation: 
Pumping lemma is negativity test. We use it to disprove that a languages is not regular.
But reverse is not true.
Question 58

WRONG

Q83 Part_A Consider the context-free grammar E → E + E E → (E * E) E → id


where E is the starting symbol, the set of terminals is {id, (,+,),*}, and the set of
nonterminals is {E}.
Which of the following terminal strings has more than one parse tree when parsed
according to the above grammar?
id + id + id + id

id + (id* (id * id))


B
(id* (id * id)) + id
C
((id * id + id) * id)

Regular languages and finite automata    Gate IT 2005    


Discuss it

Question 58 Explanation: 

According to leftmost derivation :


E -> E + E (using E -> E + E) E -> E + E + E (using E -> E + E) E -> E + E + E + E
(using E -> E + id) E -> id + E + E + E (using E -> id) E -> id + id + E + E (using E -> id)
E -> id + id + id + E (using E -> id) E -> id + id + id + id
 
According to rightmost derivation :
E -> E + E (using E -> E + E) E -> E + E + E (using E -> E + E) E -> E + E + E
+ E (using E -> E + id) E -> E + E + E + id (using E -> id) E -> E + E + id + id (using E ->
id) E -> E + id + id + E (using E -> id) E -> id + id + id + id
 
Thus, option (A) is correct.
 
Please comment below if you find anything wrong in the above post.
Question 59

WRONG

Q 83_Part B Consider the context-free grammar E → E + E E → (E * E) E → id


where E is the starting symbol, the set of terminals is {id, (,+,),*}, and the set of non-
terminals is {E}.
For the terminal string id + id + id + id, how many parse trees are possible?
5

4
B
3

2
D
Regular languages and finite automata    Gate IT 2005    
Discuss it

Question 59 Explanation: 
Background Required to solve the question - Parse Tree Construction.
Explanation : In order to produce the yield id + id + id + id ,
we only required 3 productions of type E → E + E as 3 ‘+’ are
required in the final string. This can be done in 5 ways as shown
in the picture given below:

This explanation has been provided by Pranjul Ahuja.


Question 60

WRONG

Which of the following languages is generated by the given grammar? S → aS|bS| ε 


A

B
B
C
C
D

Regular languages and finite automata    GATE-CS-2016 (Set 1)    


Discuss it
Question 60 Explanation: 
We can draw DFA using given grammar S → aS|bS| ε and generates ε, a, ab, abb, b,

aaa, .....   Therefore, language is {a, b}*. Option (D) is true.


Question 61

CORRECT

Which one of the following regular expressions represents the language: the set of all
binary strings having two consecutive 0s and two consecutive 1s?

A
A
B

C
C
D
D
Regular languages and finite automata    GATE-CS-2016 (Set 1)    
Discuss it

Question 61 Explanation: 
Option A represents those strings which either have 0011 or 1100 as substring. Option
C represents those strings which either have 00 or 11 as substring. Option D represents
those strings which start with 11 and end with 00 or start with 00 and end with 11.
Question 62

WRONG
The number of states in the minimum sized DFA that accepts the language defined by
the regular expression (0+1)*(0+1)(0+1)* is __________________ [Note that this
question was originally asked as Fill-in-the-Blanks type]
2

3
B
4

5
D
Regular languages and finite automata    GATE-CS-2016 (Set 2)    
Discuss it

Question 62 Explanation: 

 
So, the minimum number of states is 2.   Thus, B is the correct answer.
Question 63

WRONG

Consider the following two statements:


I. If all states of an NFA are accepting
states then the language accepted by
the NFA is Σ∗ .
II. There exists a regular language A such
that for all languages B, A ∩ B is regular.
Which one of the following is CORRECT?
Only I is true

Only II is true

Both I and II are true


C
Both I and II are false
D
Regular languages and finite automata    GATE-CS-2016 (Set 2)    
Discuss it

Question 63 Explanation: 
Statement I : False, Since there is no mention of transition between states. There may
be a case, where between two states there is no transition defined. Statement II: True,
Since any empty language (i.e., A = Φ ) is regular and its intersection with any other
language is Φ. Thus A ∩ B is regular. This explanation has been contributed by Shikhar
Goel.
Question 64

WRONG

In the automaton below, s is the start state and t is the only final state.

               Consider the strings u = abbaba, v =


bab, and w = aabb. Which of the following statements is true?  
The automaton accepts u and v but not w

The automaton accepts each of u, v, and w


B
The automaton rejects each of u, v, and w
C
The automaton accepts u but rejects v and w

Regular languages and finite automata    GATE IT 2006    


Discuss it

Question 64 Explanation: 
  For the acceptance and rejection of any string we can simply check for the movement
on each input alphabet between states. A string is accepted if we stop at any final state
of the DFA. For string u=abbaba the string ends at t (final state) hence it is accepted by
the DFA. For string v=bab the string ends at s (non-final state) and hence rejected by
the DFA. For string w=aabb the string ends at s (non-final state) and hence rejected by
the DFA.   This solution is contributed by Yashika Arora.
Question 65

CORRECT

In the context-free grammar below, S is the start symbol, a and b are terminals, and ϵ
denotes the empty string S → aSa | bSb | a | b | ϵ Which of the following strings is NOT
generated by the grammar?  
aaaa
A
baba

abba
C
babaaabab
D
Regular languages and finite automata    GATE IT 2006    
Discuss it

Question 65 Explanation: 
  The given Language is  Palindrome. A,C and D follow the language but  baba  is not
a palindrome  , so B is the answer
Question 66
WRONG

Which regular expression best describes the language accepted by the non-

deterministic automaton below?  


(a + b)* a(a + b)b

(abb)*
B
(a + b)* a(a + b)* b(a + b)*

(a + b)*
D
Regular languages and finite automata    GATE IT 2006    
Discuss it

Question 67

WRONG

Consider an ambiguous grammar G and its disambiguated version D. Let the language
recognized by the two grammars be denoted by L(G) and L(D) respectively. Which one
of the following is true ?
L (D) ⊂ L (G)
A
L (D) ⊃ L (G)
B
L (D) = L (G)

L (D) is empty

Regular languages and finite automata    Gate IT 2007    


Discuss it

Question 67 Explanation: 
By changing grammar, language will not change here. {as converting NFA to DFA
language will not be changed}
Question 68

WRONG

Which of the following regular expressions describes the language over {0, 1} consisting
of strings that contain exactly two 1's?
(0 + 1) * 11(0 + 1) *

0 * 110 *
B
0 * 10 * 10 *

(0 + 1) * 1(0 + 1) * 1 (0 + 1) *
D
Regular languages and finite automata    Gate IT 2008    
Discuss it

Question 68 Explanation: 
By looking at option A and D clearly not feasible solution.
Between B and C both contains exactly two 1's but in option B, both 1 will always come
together where as in C it is general string.
Question 69

WRONG

Let N be an NFA with n states and let M be the minimized DFA with m states
recognizing the same language. Which of the following in NECESSARILY true?
m ≤ 2n

n≤m
B
M has one accept state

m = 2n
D
Regular languages and finite automata    Gate IT 2008    
Discuss it

Question 69 Explanation: 
A state in a DFA is proper subset of states of NFA of corresponding DFA
=> set of states of NFA =n
=> no of subsets of a set with n elements = 2n
=> m<=2n
Question 70

CORRECT

If the final states and non-final states in the DFA below are interchanged, then which of
the following languages over the alphabet {a,b} will be accepted by the new

DFA? 
Set of all strings that do not end with ab

Set of all strings that begin with either an a or a b


B
Set of all strings that do not contain the substring ab,
C
The set described by the regular expression b*aa*(ba)*b*
D
Regular languages and finite automata    Gate IT 2008    
Discuss it

Question 70 Explanation: 
  Seemingly, DFA obtained by interchanging final and non-final states will be
complement of the given regular language. So, to prove that a family of string is
accepted by complement of L, we will in turn prove that it is rejected by L. (A). Set of all
strings that do not end with ab - This statement could be proved right by looking at the b
labeled incident edges on the final states and a labeled edges preceding them.
Complement of the given DFA will have first two states as final states. First state
doesn’t have any b labeled edge that has a labeled edge prior to it. Similarly, second
final state doesn’t have any such required b labeled edge. Similarly, it could be proven
that all the strings accepted by the given DFA end with ab. Now that L ∪ complement(L)
= (a + b) ∗ , L should be the set of all the strings ending on ab and complement(L)
should be set of all the strings that do not end with ab. [CORRECT] (B). Set of all strings
that begin with either an a or ab - This statement is incorrect. To prove that we just have
to show that a string beginning with a or ab exists, which is accepted by the given DFA.
String abaab is accepted by the given DFA, hence it won’t be accepted by its
complement. [INCORRECT] (C). Set of all strings that do not contain the substring ab -
To prove this statement wrong, we need to show that a string exists which doesn’t
contain the substring ab and is not accepted by current DFA. Hence, it will be accepted
by its complement, making this statement wrong. String aba is not accepted by this
DFA. [INCORRECT] (D). The set described by the regular expression b ∗ aa ∗ (ba) ∗ b ∗
- String abaaaba is not accepted by the given DFA, hence accepted by its com This
solution is contributed by vineet purswani.
Question 71

WRONG

Consider the following languages.

L1 = {ai bj ck | i = j, k ≥ 1}
L1 = {ai bj | j = 2i, i ≥ 0}
Which of the following is true?
L1 is not a CFL but L2 is

L1 ∩ L2 = ∅ and L1 is non-regular

L1 ∪ L2 is not a CFL but L2 is


C
There is a 4-state PDA that accepts L , but there is no DPDA that accepts L
D 1 2

Regular languages and finite automata    Context free languages and Push-down


automata    Gate IT 2008    
Discuss it

Question 71 Explanation: 
A: Both L1 and L2 are CFL
B: L1 ∩ L2 = ∅ is true
L1is not regular => true
=> B is true
C: L1 ∪ L2 is not a CFL nut L2 is CFL is closed under Union
=> False
D: Both L1 and L2 accepted by DPDA
Question 72

WRONG

Which of the following languages is (are) non-regular? L 1 = {0m1n | 0 ≤ m ≤ n ≤ 10000}


L2 = {w | w reads the same forward and backward} L3 = {w ∊ {0, 1} * | w contains an even
number of 0's and an even number of 1's}
L2 and L3 only
L1 and L2 only
B
L  only
C 3

L2 only

Regular languages and finite automata    Gate IT 2008    


Discuss it

Question 72 Explanation: 
  1. L 1 is a regular language, as it can be derived by a trivial DFA with 10000 states for
each alphabet in the grammar to limit on the number of 0s and 1s to 10000. 2. L 2 is a
set of all palindromic strings, which isn’t a regular language because there is no way for
a finite automaton to remember which alphabets have occurred. 3. L 3 is a standard
regular language as there exists a DFA which can derive this language. You can read
more in the references about
it. Reference : http://stackoverflow.com/questions/17420332/need-regular-expression-
for-finite-automata-eve 17434694#17434694 This solution is contributed by vineet
purswani.
Question 73

WRONG

Consider the following two finite automata. M1 accepts L1 and M2 accepts L2.

Which one of the following is TRUE?


L1 = L2

L1 ⊂ L2
B
L1 ∩ L2' = ∅

L1 ∪ L2 ≠ L1
D
Regular languages and finite automata    Gate IT 2008    
Discuss it

Question 73 Explanation: 
Question 74

WRONG

Which of the following intuitive definition is true about LR(1) Grammar.


For a grammar to be LR(1) it is sufficient that a left-to-right shift reduce parser be

able to recognize handles of right-sentential form when they appear on the stack.

For a grammar to be LR(1) it is sufficient that a left-to-right shift reduce parser be

B able to recognize handles of left-sentential form when they appear on the stack.
For a grammar to be LR(1) it is sufficient that a left-to-right shift reduce parser be

able to recognize handles of left-sentential form or right-sentential form when they


C
appear on the stack.

All of the above

Regular languages and finite automata    GATE 2017 Mock    


Discuss it

Question 74 Explanation: 
LR(1) – Reading the input string from left to right.
LR(1) – Deriving a right-most derivation for the string.
LR(1) – one token look-ahead
In the first choice we read from Left to right deriving the right-most sentential form and
looking one symbol ahead which is stack top. So option (a) is correct.
Question 75

CORRECT

Consider the Following regular expressions

r1 = 1(0 + 1)*
r2 = 1(1 + 0)+
r3 = 11*0
What is the relation between the languages generated by the regular expressions above
?
L (r1) ⊆ L (r2) and L(r1) ⊆ L(r3)
A
L (r1) ⊇ L (r2) and L(r2) ⊇ L(r3)

L (r1) ⊇ L (r2) and L(r2) ⊆ L(r3)


C
L (r1) ⊇ L (r3) and L(r2) ⊆ L(r1)
D
Regular languages and finite automata    GATE 2017 Mock    
Discuss it

Question 75 Explanation: 
Clearly r1 is a superset of both r2 and r3 as string 1 can not be generated by r2 and r3.
r2 is a superset of r3 as string 11 is not present in L(r3) but in L(r2).
Question 76

CORRECT

Consider regular expression r, where r = (11 + 111)* over Ʃ = {0, 1}. Number of states in
minimal NFA and DFA respectively are:
NFA – 3, DFA – 4

NFA – 3, DFA – 3
B
NFA – 3, DFA – 3
C
NFA – 4, DFA – 4
D
Regular languages and finite automata    GATE 2017 Mock    
Discuss it

Question 76 Explanation: 

For NFA: Just remove the trap state.


Question 77

WRONG

Consider the grammar G.


E -> TE’
E’ -> +TE’ | ԑ
T’ -> FT’
T’ -> *FT’ | ԑ
F -> (E) | id
If LL(1) parsing table is constructed using the grammar G, then how many entries are
present in the row that represents E’ nonterminal ? (consider the entries which are not
error/not blank entries)
1
A
2
B
3

Regular languages and finite automata    GATE 2017 Mock    


Discuss it

Question 77 Explanation: 
First (E’) = {+ ,ԑ} Follow (E’) = {$ , )}

Therefore 3 entries are present in E’ row


Question 78

WRONG

Let, init (L) = {set of all prefixes of L},


Let L = {w | w has equal number of 0’s and 1’s}
init (L) will contain:
all binary strings with unequal number of 0’s and 1’s
A
all binary strings with ԑ-string

all binary strings with exactly one more 0's than number of 1's

None of above
D
Regular languages and finite automata    GATE 2017 Mock    
Discuss it

Question 78 Explanation: 
Clearly init (L) = (0+1)*. Take any string in (0+1)* say 101011, we can append required
number of symbols to make it a member of L like 10101100.
Question 79
WRONG

Suppose M1 and M2 are two TM’s such that L(M1) = L(M2). Then
On every input on which M1 doesn’t halt, M2 doesn’t halt too.

On every i/p on which M1 halts, M2 halts too.


B
On every i/p which M1 accepts, M2 halts.

None of above.
D
Regular languages and finite automata    GATE 2017 Mock    
Discuss it

Question 79 Explanation: 
M2 accepts strings in L(M1) so definitely it will halt. Other 2 are not guaranteed as
Turing machine M does not accept w if it either rejects w by halting to a reject state or
loops infinitely on w.
Question 80

CORRECT

Consider the regular expression (0+1)(0+1)... n times. The minimum state finite
automaton that recognizes the language represented by this regular expression
contains:
n states
A
n+1 states

n+2 states
C
None of the above
D
Regular languages and finite automata    GAT
Question 81

[5 Marks question] a.  Given that A is regular and A∪B is regular, does it follow that B is
necessarily regular? Justify your answer. b.  Given two finite automata M1, M2, outline
an algorithm to decide if L(M1)⊆L(M2).    (note: strict subset)
Regular languages and finite automata    GATE CS 1999    
Discuss it
Question 82

WRONG

If the regular set 'A' is represented by A= (01+1)* and the regular set 'B' is represented
by B= ((01)* 1*)*, which of the following is true ?
A⊂B
A
B⊂A

A and B are incomparable


C
A=B

Regular languages and finite automata    GATE CS 1998    


Discuss it

Question 82 Explanation: 
Some of the regular expression always equivalent to (0+1)* such that
(0+1)*
= (0*+1*)*
= (01*)*
= (0*+1)*
= (0+1*)*
= 0*(10*)*
= 1*(01*)*
Since,
(01+1)* = ((01)* 1* )*
Therefore A = B.
Question 83

CORRECT

Which of the following sets can be recognized by a Deterministic Finite-state


Automaton?
The number 1, 2, 4, 8......,2^n,.......... written in binary.

The number 1, 2, 4,....., 2^n,.......... written in unary.


B
The set of binary strings in which the number of zeros is the same as the number

C of ones.
The set {1, 101, 11011, 1110111,.......}
D
Regular languages and finite automata    GATE CS 1998    
Discuss it

Question 83 Explanation: 
If there is a infinite language and for that language if their is no any pattern exist then
we can surely say that given language is not regular, but if pattern is exist for that
language then it may or may not be regular language and for ensuring a given language
is regular, if we are able to draw DFA for that language then surely it will be regular
otherwise not regular, Therefore option (A) is regular language as it can written in binary
i.e.,
L = {1, 10, 100, 1000, 10000, …}
Regular expression is (10*), since, for this expression we can draw DFA. So, option (A)
is correct.
Question 84

WRONG

The string 1101 does not belong to the set represented by


110* (0+1)

1(0+1)* 101
B
(10)* (01)* (00+11)*

(00+(11)*0)*

Regular languages and finite automata    GATE CS 1998    


Discuss it

Question 84 Explanation: 
R.E of option C won’t generate 1101 as you can see the language will contain L(C) =
{epsilon,10,1010,1001,0101,00,11,0011,1100,………..} Also, R.E of option D has ‘1’ but
here two ’11’ are together hence its impossible to generate 1101.L(D) =
{Epsilon,0,00,110,11110,11000,…………….} Here Option (C) and (D) both are correct.
Question 85
WRONG

Let L be the set of all binary strings whose last two symbols are same. The number of
states in the minimal state deterministic finite-state automaton accepting L is
2
A
5

3
D
Regular languages and finite automata    GATE CS 1998    
Discuss it

Question 86

WRONG

Which of the following statement is false?


Every finite subset of a non-regular set is regular
A
Every subset of a regular set is regular

Every finite subset of a regular set is regular


C
The intersection of two regular sets is regular

Regular languages and finite automata    GATE CS 1998    


Discuss it

Question 86 Explanation: 
Taking a counter example, suppose,
L1 = { a^n b^m |n ,m >=0} is always regular
L2 = { a^n b^n | n >=0} is not regular
L1 ⋂ L2 = L2
L2 which is non regular but L1 is subset of L2. Therefore Every subset of a regular set is
not regular. Option (B) is correct.
Question 87
[Subjective type] Given a regular expression for the set of binary strings where every 0
is immediately followed by exactly k 1's and preceded by atleast k 1's (k is a fixed
integer).
Regular languages and finite automata    GATE CS 1998    
Discuss it

Question 88

[Subjective type] Design a deterministic finite state automaton (using minimum number
of states) that recognizes the following language:
L = { w ∈ {0,1}* | w interpreted as a binary number (ignoring the
leading zeros) is divisible by 5 }
 
Regular languages and finite automata    GATE CS 1998    
Discuss it

Question 89

WRONG

Which one of the following regular expressions over {0,1} denotes the set of all strings
not containing 100 as a substring?
0* (1+0)*
A
0*1010*
B
0*1*01*

0*(10+1)*

Regular languages and finite automata    GATE CS 1997    


Discuss it

Question 89 Explanation: 
According to given question, it should generate all other string / substring, but in given
options :
 (A) generates 100
 (B) doesn't generate 0
 (C) doesn't generate 1
Only option (D) is correct.
Question 90

Construct a finite state machine with minimum number of states, accepting all strings
over {a, b} such that the number of a's is divisible by two and the number of b's is
divisible by three.
Question 91

Given that L is a language accepted by a finite state machine, show that L P and LR are
also accepted by some finite state machines, where
LP = {s | ss' ∈ L, for some string s' }
LR = {s | s obtainable by reversing some string in L }
Regular languages and finite automata    GATE CS 1997    
Discuss it

Question 92

Following is a state table for some finite state machine.  A).


Find the equivalence partition on the states of the machine. B). Give the state table for
the minimal machine. (Use appropriate names for the equivalent states. For example if
states X and Y are equivalent then use XY as the name for the equivalent state in the
minimal machine.)

Regular languages and finite automata    GATE CS 1997    


Discuss it

Question 93

WRONG

Which two of the following four regular expressions are equivalent? (ε is the empty
string). (i). (00)*(ε+0) (ii). (00)* (iii). 0* (iv). 0(00)*
(i) and (ii)
A
(ii) and (iii)

(i) and (iii)

(iii) and (iv)


D
Regular languages and finite automata    GATE CS 1996    
Discuss it

Question 93 Explanation: 
Here,
(00)*(ε+0)
= (00)*.ε+ (00)*.0
= (00)* + (00)*0
= 0*
It is equal to (iii) [ using regular expression properties ]. Here, we see that (00)*
generates strings of even length and (00)*0 generated the strings of odd length. Option
(C) is correct.
Question 94

WRONG

Let L ⊆ ∑* where ∑ = {a, b}. Which of the following is true ?


L = { x | x has an equal number of a's and b's } is regular

L = { anbn | n ≥ 1 } is regular


B
L = { x | x has more a's than b's } is regular
C
L = {ambn | m ? 1, n ? 1 } is regular

Regular languages and finite automata    GATE CS 1996    


Discuss it

Question 94 Explanation: 
For option (A) :- L = { x | x has an equal number of a's and b's } is regular for equal
number of a’s and b’s we need s stack for to store the number of a’s and we push all a’s
into the stack and pop all b’s for each a’s hence, a cannot be regular language. For
option (B) :- L = { anbn | n ≥ 1 } is regular is also not regular , it is same as above
language. This language also says that equal number of a’s followed by equal number
of b’s so it also need a stack to push all a’s and pop all b’s for each a’s. For option (C) :-
L= { x | x has more a's than b's } is also not regular it is also CFL we need stack here for
a should be greater than b. For option (D) :- L = {ambn | m ≥ 1, n ≥ 1 } is regular language
because there is no restriction that equal number of a’s and b’s this language only says
that a should be followed by b therefore we can draw a DFA for it. Option (D) is correct.
Question 95

CORRECT

Consider the given figure of state table for a sequential machine. The number of states

in the minimized machine will be         .


4
A
3

2
C
1
D
Regular languages and finite automata    GATE CS 1996    
Discuss it

Question 96

Given below are the transition diagrams for two finite state machine M 1 and
M2 recognizing languages L1 and
L2 respectively.                . a) Display the
transition diagram for a machine that recognizes L 1 . L2, obtained from transition
diagrams for M1 and M2 by adding only ε transitions and no new states. b) Modify the
transition diagram obtained in part(a) obtain a transition diagram for a machine that
recognizes (L1.L2)∗ by adding only ε transitions and no new states. (Final states are
enclosed in double circles).
Regular languages and finite automata    GATE CS 1996    
Discuss it

Question 97

WRONG

Consider the regular language La with input alphabets ‘a’ and ‘b’ in which count of ‘a’
and ‘b’ are odd as:
La = {w∈{a,b}* ∣|w|a∈2N+1 and |w|b∈2N+1}
What will be the minimum number of states in DFA corresponding to L a :
4

5
B
3

6
D
Regular languages and finite automata    GATE CS Mock 2018    
Discuss it

Question 97 Explanation: 
DFA will be : So, answer is 4 states.
Question 98

CORRECT

A regular expression is ambiguous when there exists a string which can be constructed
in two different ways from the regular expression. Which of the following regular
expressions are unambiguous?
a((ab)*cd)* ∪ a(ababcb*)*a*
A
aab*(ab)* ∪ ab* ∪ a*bba*
B
aaba* ∪ aaaba ∪ aabba* ∪ a

None of these
D
Regular languages and finite automata    GATE CS Mock 2018    
Discuss it

Question 98 Explanation: 
(A) Ambiguous. For instance, the string a can be constructed by using a((ab)*cd)* or
a(ababcb*)*a*. (B) Ambiguous. The string abb can be constructed either by ab* or
a*bba*. (C) Unambiguous. Option (C) is correct.
Question 99

WRONG

Consider the following languages :


(I) {anbm | n > m ∨ n < m }
(II) {anbm | n ≥ m ∨ n ≤ m }
(III) {anbm | n > m ∧ n < m }
(IV) {anbm | n ≥ m ∧ n ≤ m }
Which of the following languages are regular?
Only (I) and (IV)
A
Only (II) and (III)

Only (II), (III) and (IV)


C
None of the above

Regular languages and finite automata    GATE CS Mock 2018    


Discuss it

Question 99 Explanation: 
(I) Not regular. It is the same language as {a nbm | n ≠ m} which is the complement to
{anbm | n = m} which is not regular. Since regularity is closed under complementation, the
considered language can not be regular (since it would imply that {a nbm | n = m} is
regular). (II) Regular. The language can be described by the regular expression a*b*.
(III) Regular. This language is empty so finite and regular. (IV) Not regular. Its {a nbm |
n≥m ∧ n≤m } = {anbm | n = m} which is not regular. Therefore, option (B) is correct.
Question 100

CORRECT

Let L1, L2 be any two context-free languages and R be any regular language. Then
which of the following is/are False? (I) (L1)'∪L2∪L1 is context-free (II) R'∪L2 is context-
free (III) R∩L1∩L2 is context-free (IV) R∩L2 is context-free
I, II and IV only
A
I and III only

II and IV only
C
I only
D
Regular languages and finite automata    GATE CS Mock 2018 | Set 2    
Discuss it

Question 100 Explanation: 


Context free languages are not closed under complementary and intersection
properties. Therefore, statements (I), (III) are false. Option (B) is correct.
Question 101

CORRECT

Which of following statement(s) is/are not correct? (I) Languages generated by the
grammar S→aSa ∣ aa is not regular. (II) Languages generated by the grammar S→aSb
∣ aa is not regular. (III) Languages generated by the grammar S→S1|S3, S1→aS1c |S2|
λ, S2→aS2b|λ, S3→aS3b|S4| λ, S4→bS4c|λ is {a^nb^mc^k | k = |n - m|, n≥0, m≥0,
k≥0}. (IV) Languages generated by the grammar S→S1S3, S1→aS1c |S2|λ, S2→aS2b|
λ, S3→aS3b|S4| λ, S4→bS4c|λ is {a^nb^mc^k | k = |n - m|, n≥0, m≥0, k≥0}.
Only (II), (IV)
A
Only (I), (III), (IV)

Only (I), (II), (III)


C
All of the above
D
Regular languages and finite automata    Context free languages and Push-down
automata    GATE CS Mock 2018 | Set 2    
Discuss it

Question 101 Explanation: 


(I) Grammar S→aSa ∣ aa generates langausge (aa)+ which is regular. (II) Grammar
S→aSb ∣ aa generates langausge a^n(aa)b^n which is not regular. (III) Production rule
of S3 doesn't follow Language L, as it generates at least one word which is not in L:
abcb. (IV) Grammar generates the word acab which is not in L Therefore, only
statements (I), (III), (IV) are not correct. Option (B) is correct.
Question 102

CORRECT

Consider the Deterministic Finite Automaton for input alphabets Σ = {a, b} L


=   The number of final
state(s) will be
2
A
1
B
3

6
D
Regular languages and finite automata    GATE CS Mock 2018 | Set 2    
Discuss it

Question 102 Explanation: 


We have to Check for all the states where a > b. Say &Sigma = { 0, 1, 2 } Therefore,
final states will be = { 10, 20, 21 } Number of final states will be 3.
Question 103

CORRECT

Let δ denote the transition function and α denoted the extended transition function of the
ε-NFA whose transition table is given below:

Which of the following option is


correct?
α (q1,aba) is {q0, q2}
A
null reachable states are {q0, q1, q2}
B
α (q3,bab) is {q0, q1, q2, q3}

None of these
D
Regular languages and finite automata    GATE CS Mock 2018 | Set 2    
Discuss it

Question 103 Explanation: 


Null NFA is : Therefore, α (q1,aba) is {q0, q2,
q3}, null reachable states are {q0, q2} and α (q3,bab) is {q0, q1, q2, q3}. Only option (C)
is correct.
Question 104

WRONG

What is the language generated by this regular expression ?


(b + ε ) (a + ab)*
Always starts with b

Can have any number of ba and ab


B
Can not have 2 b's together.

Starts and end with same symbol


D
Regular languages and finite automata    GATE CS Mock 2018 | Set 2    
Discuss it

Question 104 Explanation: 


R.E. = b(a + ab)* + (a + ba)*
= (b + ε ) (a + ab)*
Or
R.E. = (a + ba)* + (a + ba)*b
= (a + ba)* (ε + b)
Both means 'Can not have 2 b's together'. Option (C) is Correct.
Question 105
WRONG

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?
k ≥ 2n
A
k≥n
B
k ≤ n2

k ≤ 2n

Regular languages and finite automata    GATE CS 2018    


Discuss it

Question 105 Explanation: 


The minimum number of state in DFA will be 1 when we have only starting state and all
other states will not be reachable from stating state. The maximum number of state in
DFA will be 2n as the number of subsets of a set with n elements in the worst case.
Therefore, k ≤ 2n Option (D) is correct. Related question - GATE | Gate IT 2008 |
Question 6
Question 106

WRONG

Given a language L, define Li as follows:


L0 = {ε}
L  = L ∙L for all i>0
i i-1

The order of a language L is defined as the smallest k such that L k=Lk+1. Consider the
language L1 (over alphabet 0) accepted by the following automaton.

The order of L1 is


______ . Note -This was Numerical Type question.
2

3
1
C
None
D
Regular languages and finite automata    GATE CS 2018    
Discuss it

Question 106 Explanation: 


L1 = ε + 0(00)* L0 = ε L1 = ε . (ε + 0(00)*)     = ε + 0(00)* = L1 L2 = L1 . L1 = L1 . L1     = (ε
+ 0(00)*) (ε + 0(00)*)     = ε + 0(00)* + 0(00)* + 0(00)* . 0(00)*     = ε + 0(00)* + 0(00)*
0(00)* = 0* Given automaton contains epsilon and even number of 0's and odd numbers
of 0's. L3 = L2 . L1     = {0*} . {ε + 0(00)*} = 0* 0(00)* = 0* So, L2 = L3 = L2+1 So, smallest
value of k = 2
Question 107

CORRECT

Which of the following regular expressions, each describing a language of binary


numbers (MSB to LSB) that represents non-negative decimal values, does not include
even values ?
0*1+0*1*
A
0*1*0+1*
B
0*1*0*1+

0+1*0*1*
D
Regular languages and finite automata    UGC-NET CS 2017 Nov - II    
Discuss it

Question 107 Explanation: 


Regular expression for binary numbers that represents non negative odd numbers: It's
LSB must be 1. So (C) option is correct.
Question 108

CORRECT

For Σ={a,b} the regular expression r = (aa)*(bb)*b denotes


Set of strings with 2 a’s and 2 b’s
A
Set of strings with 2 a’s 2 b’s followed by b
B
Set of strings with 2 a’s followed by b’s which is a multiple of 3
C
Set of strings with even number of a’s followed by odd number of b’s

Regular languages and finite automata    ISRO CS 2017    


Discuss it

Question 108 Explanation: 


We can approach this question by making refutations for wrong options: Option 1: Set of
strings with 2 a’s and 2 b’s : clearly it is wrong as the given regular expression can
accept aaaabbb. Option 2: Set of strings with 2 a’s 2 b’s followed by b Again it is wrong
as aaaabbb is a violation in this case also. Option 3: Set of strings with 2 a’s followed by
b’s which is a multiple of 3 It is wrong as aaaab is accepted by the expression. Option 4:
Set of strings with even number of a’s followed by odd number of b Clearly it is correct
as no violation exists in this case. So, correct option is (D)
Question 109

WRONG

Let L1 be regular language, L2 be a deterministic context free language and L3 a


recursively enumerable language, but not recursive. Which one of the following
statements is false?
L3 ∩ L1 is recursive

L1 ∩ L2 ∩ L3 is recursively enumerable

L1 ∪ L2 is context free
C
L1 ∩ L2 is context free
D
Regular languages and finite automata    Context free languages and Push-down
automata    Recursively enumerable sets and Turing machines    ISRO CS 2017    
Discuss it

Question 109 Explanation: 


Refer GATE-CS-2006 | Question 33 Option (A) is correct.
Question 110
WRONG

The logic of pumping lemma is an example of __________.


iteration
A
recursion
B
the divide and conquer principle

the pigeon - hole principle

Regular languages and finite automata    UGC-NET CS 2017 Nov - III    


Discuss it

Question 110 Explanation: 


Pigeon-hole principle states that if there are n pigeons fly into m hole and n > m then
atleast one hole must contain more then one pigeons. And logic of pumping lemma
states that- finite state automaton can assume only a finite number of states and
because there are infintely many input sequence, by the pigeon hole principle , there
must be atleast one state to which the automata returns over and over again. So, option
(D) is correct.
Question 111

WRONG

Pumping lemma for regular language is generally used for proving:


whether two given regular expressions are equivalent
A
a given grammar is ambiguous

a given grammar is regular


C
a given grammar is not regular

Regular languages and finite automata    UGC-NET CS 2017 Nov - III    


Discuss it

Question 111 Explanation: 


Pumping lemma is used to prove a language is regular or not. For more information on
pumping lemma Refer:Pumping_lemma So, option (D) is correct.
Question 112

WRONG

Finite state machine can recognize language generated by __________.


Only context free grammar
A
Only context sensitive grammar
B
Only regular grammar

any unambiguous grammar

Regular languages and finite automata    UGC-NET CS 2017 Nov - III    


Discuss it

Question 112 Explanation: 


Finite state machine can recognize language generated by regular grammar only. For
detailed information Refer:Designing Finite Automata from Regular Expression So,
option (C) is correct option.
Question 113

WRONG

Which one of the following is FALSE?


There is a unique minimal DFA for every regular language

Every NFA can be converted to an equivalent PDA


B
Compliment of every context-free language is recursive
C
Every non-deterministic PDA can be converted to an equivalent deterministic

PDA

Regular languages and finite automata    Context free languages and Push-down


automata    ISRO CS 2017 - May    
Discuss it
Question 113 Explanation: 
Refer: GATE-CS-2009 | Question 15
Question 114

WRONG

In some programming languages, an identifier is permitted to be a letter followed by any


number of letters or digits. If L and D denotes the set of letters and digit respectively.
Which of the following expression defines an identifier?
(L + D) *

(L.D) *
B
L(L + D) *

L(L.D) *
D
Regular languages and finite automata    ISRO CS 2017 - May    
Discuss it

Question 114 Explanation: 


Clearly, option (C) is correct as a valid identifier can only start with a letter followed by
any number of letters or digits. L(L + D) * can only generate the strings for a valid
identifier.
Question 115

WRONG

Which of the following strings would match the regular expression : p+ [3 – 5]∗ [xyz]? I.
p443y II. p6y III. 3xyz IV. p35z V. p353535x VI. ppp5
I, III and VI only
A
IV, V and VI only

II, IV and V only


C
I, IV and V only

Regular languages and finite automata    UGC NET CS 2017 Jan - II    


Discuss it
Question 115 Explanation: 
I. p443y valid
II. p6y invalid
III. 3xyz invalid
IV. p35z valid
V. p353535x valid
VI. ppp5 invalid
So, option (D) is correct.
Question 116

WRONG

A FSM(finite state machine) can be considered to be a Turing machine of finite tape


length
without rewinding capability and unidirectional tape movement

rewinding capability and unidirectional tape movement


B
without rewinding capability and bidirectional tape movement

rewinding capability and bidirectional tape movement


D
Regular languages and finite automata    ISRO CS 2016    
Discuss it

Question 116 Explanation: 


A FSM(finite state machine) can be considered to be a Turing machine of finite tape
length which has not rewinding capability and it is unidirectional tape movement.
Rewind is a procedure in which first element of input go to last element on tape and
process it and come back to starting of input tape. This is done by only Turing machine
because Turing machine can move in both direction so it is also called bidirectional. In
FSM input move from left to right, one by one but, It cannot be rewind. Option (A) is
correct.
Question 117

WRONG

Which of the following are not regular? (A) Strings of even number of a’s. (B) Strings of
a’s, whose length is a prime number. (C) Set of all palindromes made up of a’s and b’s.
(D) Strings of a’s whose length is a perfect square.
(A) and (B) only
A
(A), (B) and (C) only
B
(B), (C) and (D) only

(B) and (D) only

Regular languages and finite automata    UGC NET CS 2017 Jan - III    


Discuss it

Question 117 Explanation: 


1. Strings of even number of a’s is Regular because we can draw Finite acceptor(FA)
for this.
2. Strings of a’s, whose length is a prime number - There are infinite No. which are
prime and we can't design FA for infinite language.This is not Regular
3. Set of all palindromes made up of a’s and b’s.This is not Regular because we can't
design FA for infinite language.
4. Strings of a’s whose length is a perfect square.This is not Regular because we can't
design FA for infinite language.
So, option (C) is correct.
Question 118

WRONG

The number of strings of length 4 that are generated by the regular expression (0 +1+|
2+3+)*, where | is an alternation character and {+, *} are quantification characters, is:
08
A
09

10

12
D
Regular languages and finite automata    UGC NET CS 2016 Aug – II    
Discuss it

Question 118 Explanation: 


Possible strings of length 4 are: 0001, 0111, 0011, 0101, 0123, 2323, 2333, 2223, 2233,
2301. Total 10 strings are possible. So, option (C) is correct.
Question 119

WRONG

Which of the following is FALSE?


The grammar S→aS|aSbS|∈, where S is the only non-terminal symbol, and ∈ is

A the null string, is ambiguous.


An unambiguous grammar has same left most and right most derivation.

An ambiguous grammar can never be LR(k) for any k.

Recursive descent parser is a top-down parser.


D
Regular languages and finite automata    UGC NET CS 2016 Aug – II    
Discuss it

Question 119 Explanation: 


 The grammar S→aS|aSbS|∈, where S is the only non-terminal symbol, and ∈ is the
null string, is ambiguous.Correct
 An unambiguous grammar has same left most and right most derivation.Inorrect
 An ambiguous grammar can never be LR(k) for any k.Correct
 Recursive descent parser is a top-down parser.Correct
So, option (B) is correct.
Question 120

WRONG

The number of states required by a Finite State Machine, to simulate the behavior of a
computer with a memory capable of storing 'm' words, each of length 'n' bits is?
m x 2n
A
2
B
m+n

2mn

m+n

Regular languages and finite automata    ISRO CS 2014    


Discuss it
Question 120 Explanation: 
Given, 'm' words, each of length 'n' bits, so total number of bits = m*n A state of finite
state automata can store 1 bit of data, and a state can have either 0 or 1. Therefore,
total number of states required by a Finite State Machine = 2 mn. So, option (C) is correct.
Question 121

WRONG

How many states are there in a minimum state deterministic finite automation accepting
the language L = {w | w {0,1} number of 0's is divisible by 2 and number of 1's is
divisible by 5, respectively} ?
7
A
9

10

11
D
Regular languages and finite automata    ISRO CS 2014    
Discuss it

Question 121 Explanation: 


Here a string w of 0’s and 1’s should have the property that, the no of 0’s in the string w
should be divisible by 2 ( N(0) % 2 =0 ), and the number of 1’s the string w should be
divisible by 5 (N(1) % 5 =0). Having said that, the Language will contain the strings such
as : { ε , 00, 11111, 0011111, 0011111 , 1111100, 1010111 , 000011111,….and so on }
So, strings accepted by the automaton have to be of length 0, 2, 4, 5, 6, 7, 8, 9, 10, 11,
14, 12….and so on, i.e. equation for length will be 2x + 5y (where x,y>=0 ) Modulo 2
gives remainder as ( 0, 1 ) , and Modulo 5 gives remainder as ( 0, 1, 2, 3, 4 ). Hence 2 *
5 sates, i.e. there will be 10 states in the automaton to represent this. Option (C) is
correct.
Question 122

CORRECT
The following Finite Automaton recognizes which of the given

languages? 
{1, 0}* {01}

{1, 0}* {1}


B
{1}{1, 0}* {1}
C
1*0* {0, 1}
D
Regular languages and finite automata    ISRO CS 2014    
Discuss it

Question 122 Explanation: 


Given DFA accepts all string that ending with "01", so the language should be (0+1)*01.
Option (A) is correct,
Question 123

WRONG

The regular grammar for the language L = {a nbm | n + m is even} is given by


S → S1 | S2 S1 → a S1| A1 A1 → b A1| λ S2 → aaS2| A2 A2 → b A2| λ
A
S → S1 | S2 S1 → a S1| aA1 S2 → aaS2| A2 A1 → b A1| λ A2 → b A2| λ

S → S1 | S2 S1 → aaa S1| aA1 S2 → aaS2| A2 A1 → b A1| λ A2 → b A2| λ
C
S → S1 | S2 S1 → aa S1| A1 S2 → aaS2| A2 A1 → bb A1| λ A2 → bb A2| λ

Regular languages and finite automata    UGC NET CS 2016 Aug - III    


Discuss it

Question 123 Explanation: 


Given, language,
L = {a^n b^m | n + m is even}
Here m+n should be even for this either m, n must be even or m, n must be odd. Now
we need to generate string as { $,ab, aa , bb,abbb, aaab,aabb,.......} for this grammar
should be,
S = S1 | S2
S1 = aa S1| A1
Here, given production rules A1 derives even number of b's so we have not problem, S1
also derives even number of a's.
S2 = aaS2| A2
In this production A2 also derives odd number of b's and A2 will have even number of
a's and b's.
A1 = bb A1| λ
This production also derives even number of b's.
A2 = bb A2| λ
This derives odd number of b's all are fulfill the given condition of given language. So,
option (D) is correct.
Question 124

WRONG

Let Σ = {a, b} and language L = {aa, bb}. Then, the complement of L is


{λ, a, b, ab, ba} ∪ {w∈{a, b}* | |w| > 3}
A
{a, b, ab, ba} ∪ {w∈{a, b}* | |w| > 3}

{w ∈ { a, b}* | |w| > 3} ∪ {a, b, ab, ba}


C
{λ, a, b, ab, ba} ∪ {w ∈ {a, b}* | |w| ≥ 3}

Regular languages and finite automata    UGC NET CS 2016 Aug - III    


Discuss it

Question 124 Explanation: 


Strings generated by language L = {aa, bb} will be even length. So, complement will be
universal set of stringgs - {aa, bb}. i.e. {λ, a, b, ab, ba} and strings {w ∈ {a, b}* | |w| ≥ 3},
i.e. strings of length greater than or equal to 3. So, option (D) is correct.
Question 125
WRONG

Consider the following identities for regular expressions: (a) (r + s)* = (s + r)* (b) (r*)* =
r* (c) (r* s*)* = (r + s)* Which of the above identities are true?
(a) and (b) only

(b) and (c) only


B
(c) and (a) only
C
(a), (b) and (c)

Regular languages and finite automata    UGC NET CS 2016 Aug - III    


Discuss it

Question 125 Explanation: 


 (r + s)* will generate any strings containing r or s or both. We can draw DFA for (r
+ s)* and it is same as (s + r)*. It is a regular expression.
 (r*)* will generate any sring containing r and its DFA can be drawn easily and it is
same as r*. It is also a regular expression.
 (r* s*)* will generate any strings containing r or s or both. We can draw DFA for
(r* s*)* and it is same as (r + s)*. It is a regular expression. All option are true.
So, option (D) is correct.
Question 126

CORRECT

Given the following two languages : L1 = {uww Rν | u, v, w ∈ {a, b}+} L2 = {uwwRν | u, ν, w


∈ {a, b}+, |u| > |ν|} Which of the following is correct ?
L1 is regular language and L2 is not regular language.

L1 is not regular language and L2 is regular language.


B
Both L  and L  are regular languages.
C 1 2

Both L  and L are not regular languages.


D 1 2

Regular languages and finite automata    UGC NET CS 2016 Aug - III    


Discuss it

Question 127
WRONG

Consider the following Deterministic Finite

Automaton.   Let denote the set of eight bit


strings whose second, third, sixth and seventh bits are 1. The number of strings in that
are accepted by M is
0
A
1
B
2

Regular languages and finite automata    ISRO CS 2014    


Discuss it

Question 127 Explanation: 


Only two strings are possible with second, third, sixth and seventh bits are 1: 1)
01110110 2) 01110111
Question 128

WRONG

The number of strings of length 4 that are generated by the regular expression (0|∈)1+2*
(3|∈), where | is an alternation character, {+, *} are quantification characters, and ∈ is
the null string, is :
08
A
10
B
11

12

Regular languages and finite automata    UGC NET CS 2016 July – II    


Discuss it
Question 128 Explanation: 
Regular expression (0|∈)1+2* (3|∈) 0122, 0123, 1123, 0112, 0113, 1113, 0111, 1222,
1123, 1111, 1223, 1112; Total 12 strings of lenghth 4 are possible. So, option (D) is
correct.
Question 129

WRONG

The regular expression for the complement of the language L = {a nbm|n ≥ 4, m ≤ 3} is:
(λ + a + aa + aaa) b* + a* bbbb* + (a + b)* ba(a + b)*

(λ + a + aa + aaa) b* + a* bbbbb* + (a + b)* ab(a + b)*


B
(λ + a + aa + aaa) + a* bbbbb* + (a + b)* ab(a + b)*
C
(λ + a + aa + aaa)b* + a* bbbbb* + (a + b)* ba(a + b)*

Regular languages and finite automata    UGC NET CS 2016 July – III    


Discuss it

Question 129 Explanation: 


The complement of the language L = {anbm|n ≥ 4, m ≤ 3} is L` = {anbm|n < 4} U {anbm|m >
3}: L` = Universal set - L. L` = Universal set - {anbm|n ≥ 4, m ≤ 3} = (λ + a + aa + aaa)b* +
a*bbbbb* + (a + b)* ba(a + b)* Option (D) is giving freedom on constraints on number of
a's and number of b's. So, option (D) is correct.
Question 130

WRONG

Let L be the language generated by regular expression 0*10* and accepted by the
deterministic finite automata M. Consider the relation R M defined by M. As all states are
reachable from the start state, RM has _____ equivalence classes.
2

4
B
5
C
6
Regular languages and finite automata    UGC NET CS 
Question 131

WRONG

What are the final states of the DFA generated from the following

NFA? 
q0, q1, q2

[q0, q1], [q0, q2], [ ]


B
q0, [q1, q2]

[q0, q1], q2
D
Regular languages and finite automata    ISRO CS 2013    
Discuss it

Question 131 Explanation: 


As q0 is connected to q1 and q1 is connected to q2 through epsilon transitions, in addition
to q2, q0 and q1 are also the final states of the DFA.
Question 132

WRONG
Match the
following: 

(1)
A
(2)
B
(3)

(4)

Regular languages and finite automata    Context free languages and Push-down


automata    UGC NET CS 2015 Dec – III    
Discuss it

Question 132 Explanation: 


 {anbn | n > 0 } is a deterministic context free language but not regular language
 The complement of {anbnan| n > 0 } is context free language but not accepted by
deterministic pushdown automata
 {anbnan} is a context sensitive language but not recursive language
 L is a recursive language but not a context free languageSo, option (D) is correct.
Question 133

CORRECT

There are exactly __________ different finite automata with three states x, y and z over
the alphabet {a, b} where x is always the start state.
64
A
56
B
1024
C
5832

Regular languages and finite automata    UGC NET CS 2015 Dec – III    


Discuss it

Question 134

WRONG

Consider a language A defined over the alphabet   = {0, 1} as The


expression   The
expression   means the floor of n/2, or what you get by
rounding n/2 down to the nearest integer. Which of the following is not an example of a
string in A?
011
A
0111
B
0011

001111

Regular languages and finite automata    UGC NET CS 2015 Dec – III    


Discuss it

Question 135

WRONG

Minimal deterministic finite automaton for the language L = {0 n | n ≥ 0, n ≠ 4} will have:
1 final state among 5 states
A
4 final states among 5 states
B
1 final state among 6 states

5 final states among 6 states


Regular languages and finite automata    UGC NET CS 2015 Jun - III    
Discuss it

Question 135 Explanation: 

 Ther
e are 5 final states among 6 states. So, option (D) is correct.
Question 136

WRONG

The regular expression corresponding to the language L where L = { x ϵ {0, 1}*|x ends
with 1 and does not contain substring 00 } is:
(1 + 01) * (10 + 01)

(1 + 01) * 01
B
(1 + 01) * (1 + 01)

(10 + 01) * 01
D
Regular languages and finite automata    UGC NET CS 2015 Jun - III    
Discuss it

Question 136 Explanation: 


L = { x ϵ {0, 1}*|x ends with 1 and does not contain substring 00 }:
 (1 + 01) * (10 + 01) - This expression does not follow the condition mentioned above
i.e. it will contain 00 and can end with 0.
 (1 + 01) * 01 - It will always ends with 01.
 (1 + 01) * (1 + 01) It follows all the condition mentioned.
 (10 + 01) * 01 - It will contain 00 as substring.So, option (C) is correct.
Question 137

CORRECT

The transition function for the language L = {w|n a (w) and nb(w) are both odd} is given
by: δ (q0, a) = q1 ; δ (q0, b) = q2 δ (q1, a) = q0 ; δ (q1, b) = q3 δ (q2, a) = q3 ; δ (q2, b) = q0 δ
(q3, a) = q2 ; δ (q3, b) = q1 The initial and final states of the automata are:
q0 and q0respectively
A
q  and q respectively
B 0 1

q  and q respectively
C 0 2

q0 and q3respectively

Regular languages and finite automata    UGC NET CS 2015 Jun - III    


Discuss it

Question 137 Explanation: 


Transition diagram for L = {w|na (w) and nb(w) are both

odd}:   q3 satisf
ies the condition - {w|na (w) and nb(w) are both odd} , so q3 is final state and all strings
starts from q0 so q0 is final state. So, option (D) is correct.
Question 138

CORRECT

Given two languages: L1 = {(ab) n ak | n > k, k ≥ 0} L2 = {an bm| n ≠ m} Using pumping
lemma for regular language, it can be shown that
L1 is regular and L2 is not regular.
A
L  is not regular and L  is regular.
B 1 2

L  is regular and L  is regular.


C 1 2
L1 is not regular and L2 is not regular.

Regular languages and finite automata    UGC NET CS 2014 Dec - III    


Discuss it

Question 138 Explanation: 


Given language L1 = {(ab) n ak | n > k, k ≥ 0} here there is comparison between n and k
i.e. n should be greater than k so we need stack to perform any push and pop operation
it can solve by PDA and as we know that comparison is not allowed in finite automata.
So it not regular language. Similarly language L 2 = {an bm| n ≠ m} here we need compare
between n and m that is m should not be equal to n so again we need here a stack to
solve this PDA. And here is also comparison between n and m so it is not regular
language. Option (D) is correct.
Question 139

CORRECT

Regular expression for the complement of language L = {a n bm | n ≥ 4, m ≤ 3} is


(a + b)* ba(a + b)*
A
a* bbbbb*
B
(λ + a + aa + aaa)b* + (a + b)* ba(a + b)*
C
None of the above

Regular languages and finite automata    UGC NET CS 2014 Dec - III    


Discuss it

Question 140

WRONG
The FSM (Finite State Machine) machine pictured in the figure

above 
Complements a given bit pattern
A
Finds 2's complement of a given bit pattern
B
Increments a given bit pattern by 1

Changes the sign bit

Regular
Two finite state machines are said to be equivalent if they:
Have the same number of edges

Have the same number of states


B
Recognize the same set of tokens

Have the same number of states and edges


D
Regular languages and finite automata    UGC NET CS 2018 July - II    
Discuss it

Question 141 Explanation: 


Two finite state machines are said to be equivalent if they recognize the same set of
tokens. Having same number of edges and states doesn't mean that FA are equivalent.
So, option (C) is correct.
Question 142

WRONG
The finite state machine given in figure below

recognizes: 
any string of odd number of a’s
A
any string of odd number of b’s
B
any string of even number of a’s and odd number of b’s

any string of odd number of a’s and odd number of b’s

Regular languages and finite automata    UGC NET CS 2018 July - II    


Discuss it

Question 142 Explanation: 


 This finite state
machine will accept any string of odd number of a's and odd number of b's. So, option
(D) is correct.
Question 143

CORRECT

A pushdown automata behaves like a Turing machine when the number of auxiliary
memory is:
0
A
1
B
1 or more
C
2 or more

Regular languages and finite automata    UGC NET CS 2018 July - II    


Discuss it

Question 143 Explanation: 


A pushdown automata behaves like a Turing machine when the number of auxiliary
memory is 2 or more. PDA with 2 or more auxiliary memory have same expressive
power. Generally PDA has one auxiliary memory. So, option (D) is correct.

You might also like