Automata Gate Previous Year Questions



Ques 1Automata

Which of the following is true?

a) The intersection of two recursively enumerable languages is recursively enumerable.
b) The intersection of two recursive languages is recursive.
c) The intersection of two context free languages is context free.
d) The intersection of two regular languages is regular.


a,c,d is the correct answer.


a) is correct

The class of recursively enumerable (RE) languages is closed under intersection.
If L1 and L2 are RE languages, then L1 ∩ L2 is also RE.
This can be done by constructing a Turing machine that runs the machines for both L1 and L2 in parallel and accepts if both accept.
For example:
Let L1 = { w | w contains at least one 'a' } and L2 = { w | w contains at least one 'b' }.
Their intersection is L1 ∩ L2 = { w | w contains both 'a' and 'b' }, which is RE.

b) is incorrect

The class of recursive languages is not always closed under intersection.
If L1 and L2 are recursive, their intersection L1 ∩ L2 might not necessarily be recursive because deciding membership in L1 ∩ L2 could require undecidable steps.
For example:
Let L1 = { w | w halts on input 0 } and L2 = { w | w halts on input 1 }.
Their intersection is L1 ∩ L2 = { w | w halts on both input 0 and input 1 }, which is not recursive because the halting problem is undecidable.

c) is incorrect

The class of context-free languages (CFLs) is not closed under intersection.
There exist CFLs L1 and L2 such that their intersection L1 ∩ L2 is not a CFL.
For example:
Let L1 = { an bn cm | n, m ≥ 0 } and L2 = { am bn cn | n, m ≥ 0 }.
Their intersection is L1 ∩ L2 = { an bn cn | n ≥ 0 }, which is not a CFL.

d) is correct

The class of regular languages is closed under intersection.
If L1 and L2 are regular, then L1 ∩ L2 is also regular.
This can be achieved using the product construction of finite automata.
For example:
Let L1 = { w | w starts with 'a' } and L2 = { w | w ends with 'b' }.
Their intersection is L1 ∩ L2 = { w | w starts with 'a' and ends with 'b' }, which is regular.

So, a, c, d is correct option





Ques 2Automata

Consider the following language L = {w ∈ {0,1}*| w does not contains three or more consecutive 1's}. The number of states in minimal DFA that accepts L is


4 is the correct answer.




Ques 3Automata

Consider the following grammar:
S —> aSb|X
X —>aX|Xb|a|b
What can be said about the language generated by grammar?

a) The regular expression for language generated by the grammar is a*(a + b)b*
b) The language generated by the grammar is non-regular
c) The regular expression for language generated by the grammar is a* b*(a + b)
d) The regular expression for language generated by the grammar is (a + b)*


a is the correct answer.




Ques 4Automata

Which one of the following regular expressions correctly represents the language of the finite automaton given below?

a) (ab*bab*+ ba*aba*)
b) (ab*b)*ab+(ba*a)* ba*
c) (ab*b+ ba*a)* (a*+b*)
d) (ba*a+ ab*b)* (ab*+ba*)


d is the correct answer.




Ques 5Automata

Which of the following is/are undecidable?

a) Given two Turing machines M1and M2, decide if L(M1)=L(M2).
b) Given a Turing machine M, decide if L(M) is regular.
c) Given a Turing machine M, decide if M accepts all strings.
d) Given a Turing machine M, decide if M takes more than 1073 steps on every string.


a,b,c is the correct answer.




Ques 6Automata

Consider the following languages:

L1 = {ww | w ∈ {a, b}* }
L2 = {anbncn | m, n≥ 0}
L3 = {ambncn | m, n≥ 0}
Which of the following statements is/are FALSE?

a) L1 is not context-free but L2 and L3 are deterministic context-free.
b) Neither L1 nor L2 is context-free.
c) L2, L3, and L2 ∩ L3 all are context-free.
d) Neither L1 nor its complement is context-free.


b,c,d is the correct answer.




Ques 7Automata

Which of the following statements is/are TRUE?

a) Every subset of a recursively enumerable language is recursive.
b) If a language L and its complement L are both recursively enumerable, then L must be recursive.
c) The complement of a context-free language must be recursive.
d) If L1 and L2 are regular, then L1∩ L2 must be deterministic context-free.


b,c,d is the correct answer.




Ques 8Automata

Suppose that L1 is a regular language and L2 is a context-free language. Which one of the following languages is NOT necessarily context-free?

a) L1∩L2
b) L1⋅L2
c) L1−L2
d) L1∪L2


c is the correct answer.




Ques 9Automata

Consider the following statements.

  • S1: The sequence of procedure calls corresponds to a preorder traversal of the activation tree.
  • S2: The sequence of procedure returns corresponds to a postorder traversal of the activation tree.
Which one of the following options is correct?

a) S1 is true and S2 is false
b) S1 is false and S2 is true
c) S1 is true and S2 is true
d) S1 is false and S2 is false


c is the correct answer.




Ques 10Automata

Consider the following languages.

L1 = { wxyx ∣ w,x,y ∈ (0+1)+ }
L2 = { xy ∣ x,y ∈ (a+b)*, ∣x∣=∣y∣, x≠y }

Which one of the following is TRUE ?

a) L1 is regular and L2 is context- free
b) L1 context- free but not regular and L2 is context-free
c) Neither L1 nor L2 is context- free
d) L1 context- free but L2 is not context-free


a is the correct answer.




Ques 11Automata

Which of the following languages are undecidable? Note that ⟨M⟩ indicates encoding of the Turing machine M.

L1 = { ⟨M⟩ ∣ L(M)=∅ }
L2 = { ⟨M,w,q⟩ ∣ M on input w reaches state q in exactly 100 steps }
L3 = { ⟨M⟩ ∣ L(M) is not recursive }
L4 = { ⟨M⟩ ∣ L(M) contains at least 21 members }

a) L1, L3, and L4 only
b) L1, and L3 only
c) L2, and L3 only
d) L2, L3 and L4 only


a is the correct answer.




Ques 12Automata

Consider the language L = { an ∣ n≥0 }∪{ anbn∣ n≥0 } and the following statements.
I. L is deterministic context-free.
II. L is context-free but not deterministic context-free.
III. L is not LL(k) for any k.
Which of the above statements is/are TRUE ?

a) Ⅰ only
b) Ⅱ only
c) Ⅰ and Ⅲ only
d) Ⅲ only


c is the correct answer.




Ques 13Automata

Consider the following statements
I. If L1∪L2 is regular, then both L1 and L2 must be regular.
II. The class of regular languages is closed under infinite union.
Which of the above statements is/are TRUE ?

a) Ⅰ only
b) Ⅱ only
c) Both Ⅰ and Ⅱ
d) Neither Ⅰ nor Ⅱ


d is the correct answer.




Ques 14Automata

Which one of the following regular expressions represents the set of all binary strings with an odd number of 1′s ?

a) ((0+1)*1(0+1)*1)*10*
b) (0*10*10*)*0*1
c) 10*(0*10*10*)*
d) None


d is the correct answer.




Ques 15Automata

Consider the following language.

L = { x∈{a,b}* ∣ number of a’s in x divisible by 2 but not divisible by 3 }


The minimum number of states in DFA that accepts L is _________ .


6 is the correct answer.




Ques 16Automata

Consider the following language.
L = { x∈{a,b}* ∣ number of a’s in x divisible by 2 but not divisible by 3 }
The minimum number of states in DFA that accepts L is _________ .


6 is the correct answer.




Ques 17Automata

Let Σ be the set of all bijections from {1, ..., 5} to {1, ..., 5}, where id denotes the identity function, i.e. id(j) = j,∀ j. Let ° denote composition on functions. For a string x = x1 x2 ... xn ∈ Σn, n ≥ 0, let π(x) = x1°x2° ... °xn. Consider the language L = {x ∈ Σ* ⏐ π(x) = id}. The minimum number of states in any DFA accepting L is _________ .


120 is the correct answer.




Ques 18Automata

Consider the following sets:

S1: Set of all recursively enumerable languages over the alphabet {0, 1}.
S2: Set of all syntactically valid C programs.
S3: Set of all languages over the alphabet {0, 1}.
S4: Set of all non-regular languages over the alphabet {0, 1}.


Which of the above sets are uncountable?

a) S1 and S2
b) S3 and S4
c) S1 and S4
d) S2 and S3


b is the correct answer.




Ques 19Automata

Which one of the following languages over ∑ = {a, b} is NOT context-free?

a) {wwR ⏐ w ∈ {a, b}*}
b) {wwR ⏐ w ∈ {a, b}*}
c) {wanwRbn ⏐ w ∈ {a, b}*, n≥ 0}
d) {anbii⏐ i ∈ {n, 3n, 5n}, n≥ 0}


c is the correct answer.




Ques 20Automata

For Σ = {a, b}, let us consider the regular language

L = {x ∣ x = a2+ 3k or x = b10 + 12k, k ≥ 0}


Which one of the following can be a pumping length (the constant guaranteed by the pumping lemma) for L?

a) 3
b) 5
c) 9
d) 24


Regular Language is the correct answer.




Ques 21Automata

Consider the following languages:

I. {ambncpdq ∣ m + p = n + q, where m, n, p, q ≥ 0}
II. {ambncpdq ∣ m = n and p = q, where m, n, p, q ≥ 0}
III. {ambncpdq ∣ m = n = p and p ≠ q, where m, n, p, q ≥ 0}
IV. {ambncpdq ∣ mn = p + q, where m, n, p, q ≥ 0}


Which of the above languages are context-free?

a) I and IV only
b) I and II only
c) II and III only
d) II and IV only


Context Free Grammar is the correct answer.




Ques 22Automata

The minimum possible number of states of a deterministic finite automaton that accepts a regular language L = {w1aw2 | w1, w2 ∈{a,b}* , |w1| = 2, w2>=3} is_______


a is the correct answer.




Ques 23Automata

Identity the language generated by following grammar where S is the start variable.

S --> XY
X --> aX | a
Y --> aYb | ∈

a) {am bn| m>=n, n>0 }
b) {am bn| m>=n, n>=0 }
c) {am bn | m>n, n>=0 }
d) {am bn| m>n, n>0 }


Grammar is the correct answer.




Ques 24Automata

Let L1 and L2 be any context-free language and R be any regular language. Then, which of the following is correct ?

I. L1 ∪ L2 is context-free.
II. L1' is context-free.
III. L1-R is context-free.
IV. L1 ∩ L2 context-free.

a) I only
b) I and III only
c) II and IV only
d) I, II and IV only


Regular Language is the correct answer.




Ques 25Automata

Consider the following grammar:

stmt -> if expr then else expr; stmt | ε
expr -> term relop term | term
term -> id | number
id -> a | b | c
number -> [0-9]


where relop is a relational operate (e.g < >, ….), ε refers to the empty statement, and if ,then, else are terminals. Consider a program P following the above grammar containing ten if terminals. The number of control flows paths in P is ____________. For example, the program

if e1 then
    e2
else
    e3

has 2 control flow paths, e1 -> e2 and e1 -> e3


a is the correct answer.




Ques 26Automata

Consider the language L given by the regular expression (a + b)*b(a +b) over the alphabet {a, b}. The smallest number of states needed in a deterministic finite-state automaton (DFA) accepting L is ______.


4 is the correct answer.




Ques 27Automata

Let A and B be infinite alphabets and let # be a symbol outside both A and B. Let f be a total functional from A* to B* .We say f is computable if there exists a Turning machine M which given an input x in A*, always halts with f(x) on its tape. Let Lf denotes the language {x#f(x)|x∈A*}. Which of the following statements is true?

a) f if computable if and only if Lf is recursive.
b) f if computable if and only if Lf is recursive enumerable.
c) if f is computable then Lf is recursive, but not conversely.
d) if f is computable then Lf is recursively enumerable, but not conversely.


a is the correct answer.




Ques 28Automata

Consider the following languages over the alphabet ∑= {a,b,c}.
Let L1 ={anbncm | m, n >= 0 } and
L2 = {ambncn| m, n >= 0}.

Which of the following are context-free languages ?
I. L1 ∪ L2
II. L1 ∩ L2

a) I only
b) II only
c) I and II
d) Neither I nor II


a is the correct answer.




Ques 29Automata

If G is grammar with productions

S → SaS | aSb | bSa | SS | ∈


where S is the start variable, then which one of the following is not generated by G?

a) abab
b) aaab
c) abbaa
d) babba


CFG is the correct answer.




Ques 30Automata

Consider the following grammar over the alphabet {a,b,c} given below, S and T are non-terminals.

G1: S-->aSb|T
T--> cT|∈
G2: S-->bSa|T
T--> cT|∈

The language L1(G1) ∩ L2(G2).

a) Finite
b) Non-finite but regular
c) Context-free but not regular
d) Recursive but not context-free


b is the correct answer.




Ques 31Automata

Consider the following context-free grammar over the alphabet ∑ = {a, b, c} with S as the start symbol:

S → abScT | abcT
T → bT | b


Which of the following represents the language generated by the above grammar?

a) {(ab)n(cb)n | n >= 1 }
b) {(abncbm1cbm2...cbmn | n, m1, m2, ....., mn >= 1 }
c) {(ab)n(cbm)n | n >= 1 }
d) {(ab)n(cbn)m | m, n >= 1 }


b is the correct answer.




Ques 32Automata

Consider the following grammar

P→xQRS
Q→yz|z
R→ w|∈
S→y

Which is FOLLOW(Q)?

a) {R}
b) {w}
c) {w, y}
d) {w, ∉}


FIRST and FOLLOW is the correct answer.




Ques 33Automata

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 __________________


a is the correct answer.




Ques 34Automata

A student wrote two context-free grammars G1 and G2 for generating a single C-like array declaration. The dimension of the array is at least one. For example,

int a[10][3];
The grammars use D as the start symbol, and use six terminal symbols int ; id [ ] num.

Grammar G1
D → int L;
L → id [E
E → num]
E → num] [E

Grammar G2
D → int L;
L → id E
E → E[num]
E → [num]

Which of the grammars correctly generate the declaration mentioned above?

a) Both G1 and G2
b) Only G1
c) Only G2
d) Neither G1 nor G2


CFG is the correct answer.




Ques 35Automata

Which one of the following grammars is free from left recursion?

a) S → AB
A → Aa | b
B → c
b) S → Ab | Bb | c
A → Bd | ε
B → e
c) S → Aa | B
A → Bb | Sc | ε
B → d
d) S → Aa | Bb | c
A → Bd | ε
B → Ae | ε


Grammar is the correct answer.




Ques 36Automata

Consider the following languages.

L1 = {(M) | M takes at least 2016 steps on some input},
L2 = {(M) | M takes at least 2016 steps on all inputs} and
L3 = {(M) | M accepts ε},

where for each Turing machine M, denotes a specific encoding of M. Which one of the following is TRUE?

a) L1 is recursive and L2, L3 are not recursive
b) L2 is recursive and L1, L3 are not recursive
c) L1, L2 are recursive and L3 is not recursive
d) L1, L2,L3 are recursive


Turing Machine is the correct answer.




Ques 37Automata

Consider the following languages:

L1= {anbmcn+m : m, n >= 1}
L2= {anbnc2n : n >= 1}

Which one of the following is TRUE?

a) Both L1 and L2 are context-free.
b) L1 is context-free while L2 is not context-free.
c) L2 is context-free while L1 is not context-free.
d) Neither L1 nor L2 is context-free.


CFG is the correct answer.




Ques 38Automata

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?

a) Only I is true
b) Only II is true
c) Both I and II are true
d) Both I and II are false


DFA is the correct answer.




Ques 39Automata

Consider the following types of languages:

L1 Regular,
L2: Context-free,
L3: Recursive,
L4: Recursively enumerable.

Which of the following is/are TRUE?

I. L3' U L4 is recursively enumerable
II. L2 U L3 is recursive
III. L1* U L2 is context-free
IV. L1 U L2' is context-free

a) I only
b) I and III only
c) I and IV only
d) I, II and III only


Languages is the correct answer.




Ques 40Automata

Language L1 is defined by the grammar:
S1 -> aS1b | ε
Language L2 is defined by the grammar:
S2 -> abS2 | ε
Consider the following statements:

P: L1 is regular
Q: L2 is regular

Which one of the following is TRUE?

a) Both P and Q are true
b) P is true and Q is false
c) P is false and Q is true
d) Both P and Q are false


Regular Grammar is the correct answer.




Ques 41Automata

Let X be a recursive language and Y be a recursively enumerable but not recursive language. Let W and Z be two languages such that Y reduces to W, and Z reduces to X (reduction means the standard many-one reduction). Which one of the following statements is TRUE?

a) W can be recursively enumerable and Z is recursive.
b) W an be recursive and Z is recursively enumerable.
c) W is not recursively enumerable and Z is recursive.
d) W is not recursively enumerable and Z is not recursive


Recursive Language is the correct answer.




Ques 42Automata

Consider the following context-free grammars:

G1: S → aS|B, B → b|bB
G2: S → aA|bB, A → aA|B|ε, B → bB|ε

Which one of the following pairs of languages is generated by G1 and G2, respectively?

a) {ambn |m > 0 or n > 0} and {ambn |m > 0 and n > 0}
b) {ambn |m > 0 and n > 0} and {ambn |m > 0 or n ≥ 0}
c) {ambn |m ≥ 0 or n > 0} and {ambn |m > 0 and n > 0}
d) {ambn |m ≥ 0 and n > 0} and {a mbn |m > 0 or n > 0}


CGF is the correct answer.




Ques 43Automata

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) (0+1)*0011(0+1)* + (0+1)*1100(0+1)*
b) (0+1)* (00(0+1) *11+11(0+1)*00)(0+1)*
c) (0+1)*00(0+1) *+ (0+1) *11(0+1) *
d) 00(0+1) *11+11(0+1)*00


Regular Language is the correct answer.




Ques 44Automata

Which of the following decision problems are undecidable?

I. Given NFAs N1 and N2, is L(N1)∩L(N2) = Φ?
II. Given a CFG G = (N,Σ,P,S) and a string x ∈ Σ*, does x ∈ L(G)?
III. Given CFGs G1 and G2, is L(G1) = L(G2)?
IV. Given a TM M, is L(M) = Φ?

a) I and IV only
b) II and III only
c) III and IV only
d) II and IV only


decidablility is the correct answer.




Ques 45Automata

Which of the following languages is generated by the given grammar?

S → aS|bS| ε

a) {anbm | m,n >= 0}
b) {w∈{a,b}* | w has equal number of a's and b's}
c) {an | n>=0} U {anbn | n>=0}
d) {a,b}*


Grammar is the correct answer.




Ques 46Automata

For any two languages L1 and L2 such that L1 is context free and L2 is recursively enumerable but not recursive, which of the following is/are necessarily true?

I. L1' (complement of L1) is recursive
II. L2' (complement of L2) is recursive
III. L1' is context-free
IV. L1' ∪ L2 is recursively enumerable

a) I only
b) III only
c) III and IV only
d) I and IV only


CFG is the correct answer.




Ques 47Automata

Which one of the following is TRUE?

a) The Language L={ an bn | n≥ is regular }
b) The Language L={ an | n is prime }
c) The Language L={ w | w has 3k+1 b's for some k ∈ N with Σ ={a,b}} is regular
d) The Language L={ww | w ∈ Σ with Σ ={0,1}} is regular


Regular Grammar is the correct answer.