TOC - Basic Final
TOC - Basic Final
What is the highest type number that can be assigned to the following grammar?
(A)Type 0
(B) Type1
(C) Type2
(D) Type 3
Q3. Consider the following grammar G with start symbol S
S→Aa,
A→Ba,
B→abc.
What is the highest type number that can be assigned to the following grammar?
(A) Type 0
(B) Type 1
(C) Type 2
(D) Type 3
Q11. Consider the language L = {w : for some u Σ*, w = uRu}. Which of the following
strings belongs to L?
(i) aaabbb (ii) abab (iii) abba (iv)
(A) (i) and (ii)
(B) (iii) only
(C) (iv) only
(D) (iii) and (iv)
(Q7
Q12. Consider the grammar G:
S → AB
A → 0A1 | 2
B → 1B | 3A
Which of the following strings is in L(G)?
(A) 0211300021
(B) 021300211
(C) 00213021
(D) 0021113002111
Q13. Identify in the list below a sentence of length 6 that is generated by the grammar
S →(S)S| λ
(A) ( ) ( ) ( )
(B) ) ) ) ( ( (
(C) ) ) ( ( ) (
(D) ) ( ( ) ( )
Q16. Which of the following strings cannot be derived from the symbol S using the rules
S → SS | aaa | aaaaa ?
(A) aaaaaa
(B) aaaaaaa
(C) aaaaaaaa
(D) aaaaaaaaa
Q18. 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 string is not generated by given grammar?
(A) ababcbbcbbb (B) ababcbcb
(C) abababcbcbbcbb (D) ababcbcbbcb
Q19. Consider the following grammar
S → XY | W
X → aXb |
Y → cY |
W → aWc | Z
Z → bZ |
What is the language generated by this grammar?
(A){ aibjck | i, j, k ≥ 0, and i = j = k }
(B){ aibjck | i, j, k ≥ 0, and i = j or i = k }
(C){ aibjck | i, j, k ≥ 0, and i = j or j = k }
(D){ aibjck | i, j, k ≥ 0, and i ≠ j or i ≠ k }
Q31. Consider the following grammar G with start symbol S over the alphabet Σ = {a, b}
S → aXa | bXb | a | b
X → aX | bX | λ
The language generated by G is
(A) All strings that start and end with the same symbol.
(B) All nonempty strings that start and end with the different symbol.
(C) All nonempty strings that start and end with the same symbol.
(D) None of the above.
Q34. Consider the following grammar G with start symbol S over the alphabet Σ = {a, b}
S → Aa | MS | SMA
A → Aa | λ
M → λ | MM | bMa | aMb
The language generated by G is
(A) All strings with more a’s than b’s.
(B) All strings with one more a’s than b’s.
(C) All strings with more b’s than a’s.
(D) All strings with equal a’s and b’s.
Q37. Which of the following is not in the set of strings denoted by the regular expression
R = (a* b c*)*?
(A) aabc (B) bacd
(C) abcbc (D) babbc
Q38. Which of the following strings are generated by the regular expression
(ab)*..(a+b+∅).ba?
(i) (ii) aba
(iii) ababba
(iv) abababa
(A) ii, iii and iv only
(B) ii and iv only
(C) i and ii only
(D) All the above
Q39. Which of the following strings is a member of the language described by the regular
expression: (a*ba*ba*ba*)*
(A) bbbb (B) bbaaabb
(C) bbaaabbbabb (D) bbabbbab
Q60. Let = {0, 1}, and language over, L = {*| contains odd number of 1’s}. Which
Of the following regular expression best describes the given language?
(A) 0*(10*10*)*10* (B) 0*1(11)* 0*
(C) 0*1*0*1*0*1 (D) 1(11)*
Q61. Let = {0, 1}, and language over ,
L = {*| any two 0’s in are separated by three 1’s}. Which of the following
regular expression best describes the given language?
(A) (01110)* (B) (01110)* + 1*
(C) 1*(01110)* + 1* (D) 1*(0111)*01* + 1*
Q62. Let = {0, 1}, and language over, L = {*| is a binary number divisible by 4}.
Which of the following regular expression best describes the given language?
(A) (0+1)*00 (B) (0+1)*0
(C) (0+1)* 000 (D) (0+1)* 100
Q66. Consider the language defined by the regular expression (a|b)*b+. Which of the
following regular expression(s) also define that language?
(1) (a*b+) | (b*b+)
(2) (ab | bb)* b*
(3) (a | b | ba)*b+
(A) (1) and (2)
(B) (2) and (3)
(C) Only (3)
(D) Only (2)
Q67. Which of the following defines a language different than the others?
(A)The regular expression (a | b)* a b c
(B) The regular expression (a* b*)* a b c
(C)The regular expression (a | b) (a | b)* c
(D)All are same
(A) I only
(B) II only
(C) Both I & II
(D) Neither I nor II
Q69. What is the best description of languages denoted by the following regular
expression R = 0( 0+1)*0?
(A) strings of zeros and ones with zeros occurring more frequently than ones
(B) strings from alphabet {0,1} which begin and end with a zero
(C) strings from alphabet {0,1} which begin and end with a zero and have an even
number of zeroes
(D) strings from alphabet {0,1} which begin with one or more zeros, followed by zero
or more 3ones, followed by a zero.
Q70. What is the best description of the languages denoted by the following regular
expressions R = ((11 + 0)*)*
(A)strings from the alphabet {0,1} in which there are an even number of 1s
(B) strings from the alphabet {0,1} in which ones always appear in pairs
(C) strings from the alphabet {0,1} in which ones occur twice as frequently as zeros
(D) strings from the alphabet {0,1} in which there are an even number of 1s and an
odd number of zeroes.
Q73. How many strings of length less than 4 contains the language described by the
regular expression (a + d)*b(a + bc)*?_______
Q74. How many strings are there in the language defined by regular expression?
__________((∅*∩ a) ∪ (∅∪ b*)) ∩ ∅*
Q75. How many strings are there in the language defined by regular
expression?__________((∅*∪ b) ∩ (b*∪∅))
Q76. How many strings of length less than 5 contains the language described by the
regular expression 0*1(0 + 1)* 01*? ______________
Q77. Let L be the language generated by regular expression ((a + b)*b(a + ab)*). How many
strings of length less than four are there in L? ______
Q78. What is the regular expression for the language generated by the following grammar?
S →Aab A→ Aab | B B→a
(A) aab(ba)*
(B) aab(ab)*
(C) aa(ab)*
(D) ab(ab)*
Q81. Which of the following grammar generates the language generated by given regular
expression R = a(a+b)*a + b(a+b)*b
(A) S aSa | bSb | aS | bS | λ
(B) S aAa | bAb A aA | bA | λ
(C) S aAa | bAb A aA | bA | aAa | bAb| λ
(D) Both b & c
Q82. Which of the following grammar generates the language generated by given regular
expression R = aaa+ + (ba+bb)*a
(A) S aaX | Ya X aX | λ YbaYbbY | λ
(B) S aX | Ya X aX | a YbaY | bbY | λ
(C) S aaX | Ya X aX | a YbaY | bbY | λ
(D) None of the above
If string s is accepted by this DFA, which of the following strings cannot be a suffix of
s?
(A)111
(B) 111001
(C) 11011
(D) 0010111
Q89. How many of the following strings are accepted by the NFA given below? ________
(i) 00
(ii) 01001
(iii) 10010
(iv) 000
(v) 0000
Q90. Which of the following strings is accepted by DFA given below?
(A) aabbbcca
(B) aabbbcccca
(C) abbbcccc
(D)bccccabc
(A) ∅
(B) {}
(C) a*
(D) a+
Data for next two questions: Consider the following DFA D: (New Question)
Q92. Let the language accepted by G is L(D) then complement of L(D) is equivalent to
(A) 1+ (B) 1*
(C) 1* + 0* (D) 1(0+1)*
Q93. Let the language accepted by G is L(D) then reverse of L(D) is equivalent to
(A) 01* (B) 1*0(0+1)*
(C) (0+1)*01* (D) (0+1)* + 01*
Data for next twenty questions: Consider the following two DFA’s D1 and D2:
It is given the language accepted by D1 and D2 are L (D1) and L (D2), respectively.
Q95. If L(D) = L(D1) ∩ L(D2), then the regular expression for L(D) is equivalent to
(A) ∅ (B) (01 + 10)(0 + 1)*
(C) (00*1 + 11*0)(0 + 1)* (D) None of these
Q96. If L(D) = L(D1) − L(D2), then the regular expression for L(D) is equivalent to
(A) 1* (B) 1+
(C) 1(0 + 1)* (D) None of these
Q97. If L(D) = L(D1).L(D2), then the regular expression for L(D) is equivalent to
(A) 0*11*0 (0 + 1)* (B) 0*1(0+1)*1*0(0+1)*
(C) (0 + 1)* (D) (0 + 1)+
Q98. If L(D) = L(D1)R.L(D2)R, then the regular expression for reverse of L(D) is
(A) (0 + 1)* (B) (0 + 1)*1*0(0 + 1)*10*
(C) 0*1(0 + 1)*1*0(0 + 1)* (D) (0 + 1)*01*(0 + 1)*10*
Q99. If L(D) = L(D1) ∪ L(D2), then the regular expression for complement of L(D) is
(A) λ (B) 0+ + 1+
(C) 0* + 1* (D) 0*1*
Q100. If L(D) = L(D1) ∩ L(D2), then the regular expression for complement of L(D) is
(A) λ (B) 0+ + 1+
(C) 0* + 1* (D) (0+1 + 1+0)(0+1)*
Q101. [MSQ]
If L(D) = L(D1)*∪ L(D2)*, then which of the following regular expression is/are
equivalent to L(D)?
(A) (01 + 10)* (B) (0 + 1) *
(C) 0*1*(0+1)* (D) none of these
Q103. Minimum how many states are required to construct the DFA for L(D1) ∩ L(D2)? ____
̅̅̅̅̅̅̅̅ ∩ 𝐿(𝐷2)
Q104. Minimum how many states are required to construct the DFA for 𝐿(𝐷1) ̅̅̅̅̅̅̅̅? ____
̅̅̅̅̅̅̅̅ ∪ 𝐿(𝐷2)
Q105. Minimum how many states are required to construct the DFA for 𝐿(𝐷1) ̅̅̅̅̅̅̅̅? ____
̅̅̅̅̅̅̅̅ . 𝐿(𝐷2)
Q106. Minimum how many states are required to construct the DFA for 𝐿(𝐷1) ̅̅̅̅̅̅̅̅? ____
Q107. Minimum how many states are required to construct the DFA for L(D1) . L(D2)? ____
Q108. [MSQ]
Which of the following Grammars accept the language L(D1) ∪ L(D2)?
(A) S 0S | 1S | 0 | 1
(B) S 0A | 1B, A 0A | λ, B 1B | λ
(C) S 0S1 | 1S0 | 0S | 1S | 0 | 1
(D) None of the above
Q109. [MSQ]
Which of the following Grammars accept the language L(D1) ∩ L(D2)?
(A) S 0X1A | 1Y0A, X 0X | λ, Y 1Y | λ, A 0A | 1A | λ
(B) S XY, X 0A1 | 1B0, A 0A | λ, B 1B | λ, Y 0Y | 1Y | λ
(C) S 0S | 1S | 0 | 1
(D) None of the above
Q110. [MSQ]
Which of the following Grammars accept the language L(D1)R ∪ L(D2)R?
(A) S 0S | 1S | 0 | 1
(B) S 0A | 1B, A 0A | λ, B 1B | λ
(C) S 0S1 | 1S0 | 0S | 1S | 0 | 1
(D) None of the above
Q112. [MSQ]
Which of the following Grammar(s) accept the language ̅̅̅̅̅̅̅̅
𝐿(𝐷1) . ̅̅̅̅̅̅̅̅
𝐿(𝐷2)?
(A) S 0S | 1S
(B) S λ
(C) S 0S | 1S | 0 | 1
(D) S XY X 0X | λ Y 1S | λ
̅̅̅̅̅̅̅̅ ∩ 𝐿(𝐷2)
Q113. Which of the following Grammar accepts the language 𝐿(𝐷1) ̅̅̅̅̅̅̅̅?
(A) S 0S | 1S
(B) S λ
(C) S 1S | 0S | 0 | 1
(D) None of the above
If the language accepted by M is L(M) then the regular expression for reverse of
L(M)
is
(A) (a + b)*{λ + a + aa + aab + aaba + aabbab}
(B) (aabab)(a + b)*
(C) babaa (a + b)*
(D) None of the above
Q116. [MSQ]
Consider the following NFA with (epsilon):
Which of the following option(s) is/are true about -closure of different states of
given NFA?
(A (D)
∈ −𝑐𝑙𝑜𝑠𝑢𝑟𝑒 (𝑝) = {𝑝, 𝑞, 𝑟} ∈ −𝑐𝑙𝑜𝑠𝑢𝑟𝑒 (𝑝) = {𝑝, 𝑞, 𝑟}
∈ −𝑐𝑙𝑜𝑠𝑢𝑟𝑒 (𝑞 ) = {𝑝, 𝑞, 𝑟} ∈ −𝑐𝑙𝑜𝑠𝑢𝑟𝑒 (𝑞 ) = {𝑞, 𝑟}
∈ −𝑐𝑙𝑜𝑠𝑢𝑟𝑒 (𝑟) = {𝑝, 𝑞, 𝑟} ∈ −𝑐𝑙𝑜𝑠𝑢𝑟𝑒 (𝑟) = { 𝑟}
(C) (D)
∈ −𝑐𝑙𝑜𝑠𝑢𝑟𝑒 (𝑝) = {𝑝, 𝑞, 𝑟} None of these
∈ −𝑐𝑙𝑜𝑠𝑢𝑟𝑒 (𝑞 ) = {𝑞}
∈ −𝑐𝑙𝑜𝑠𝑢𝑟𝑒 (𝑟) = {𝑟}
(A)ac + b(ab)*
(B) (ac + b)(aac + ab)*
(C)(aca +ba)(b + ac)*
(D) Both b and c
(1) 0*(11)*0*
(2) 0*1(10*1)*1
(3) 0*1(10*1)*10∗
(4) 0*1(10*1)0(100)*
(5) (0*1(10*1)*10* + 0*)*
Q124. What is the language accepted by the following finite state automata?
(A) a*(a+b)b
(B) a*(a+b)ba*
(C) a*{((a+b)b)*a* + λ}
(D) (a +(a+b)b)*
(A) All strings of the form 0+w, where w contains an even number of ones.
(B) All strings of the form 000+w, where w contains an even number of ones.
(C) All strings of the form 00+w, where w contains an odd number of ones.
(D) All strings of the form 00+w, where w contains an even number of ones.
(A) L= {w| w has number of ‘a’ divisible of 4 and number of ‘b’ divisible of 3}
(B) L= {w| w has exactly two a’s and at least two b’s}
(C) L= {w | w has exactly two a’s and number of b’s divisible by 2}
(D) L= {w | w has at least two a’s and number of b’s divisible by 2}
(A)L= {w| w has an even number of a’s and one or two b’s}
(B)L= {w| w has an even number of a’s and at least two b’s}
(C)L= {w| w has an at least two a’s and one or two b’s}
(D)L= {w| w has an at least two a’s and one or two b’s}
(A) (00+11)+
(B) All the strings containing 00 and 11 as substring
(C) All the strings end with 00 or 11
(D) All the strings of length greater than or equal to two
Let the language accepted by DFA1 is L1 and that of DFA2 is L2. Which of the
following is true?
(A) L1 L2 (B) L2 L1
(C) L1= L2 (D) L1 ≠ L2
Q137. Minimum number of states in a deterministic finite state automaton (FSA) that
recognizes all strings over a and b that has at least three a’s and at least two b’s i.e.
L = {w| w has at least three a’s and at least two b’s}__________
Q140. The minimum number of state in the DFA for the language
L = {w |(na(w)+ 2nb (w)) mod 3 < 2} is ______
Q141. How many number of states are required to construct the minimized DFA for
following languages over {a, b} whose languages of accepted strings (exactly) are:
(i) {a, aa, aaa, aaaa}. ________
(ii) all strings not in {a, aa, aaa, aaaa}. ____________
(iii) all strings whose length is divisible by 2 or 3. ___________
(iv) all strings matching the regular expression (aa|b)*+(bb|a)*.____
(v) all strings not matching the regular expression (*)*_________
The number of states in the equivalent minimized DFA will be? ____________
The number of states in the equivalent minimized DFA will be? ___________
Q147. Consider the following NFA
The number of states in the equivalent minimized DFA will be? _________
Q148. Consider the following DFA D over the alphabet ΣD = {a, b, c}:
Q149. Find out how many states exist when we draw minimized DFA for the regular
language given below L = {w x wr |w(a+b)+ and x(a+b)*} ?__________
Q152.
S Suppose we apply minimization to the following DFA over {a, b}:
Q155. Suppose we have a DFA D = (Q, Σ, δ, q0, F) and know that D accepts every string.
Q156. Let A = {0n1m | n<=m} and B = {0n1m | m<=n} then which options are incorrect?
(i) A U B is regular.
(ii) A intersection B is regular.
(iii) Both A and B are regular.
(A) ii & iii only (B) i & ii only
(C) i & iii only (D) All
Q160. For which of the following languages over the alphabet {a, b} is /are not regular?
Q161. For which of the following languages over the alphabet {a, b} is/are regular?
1. L = {anbman : m, n 0}
2. L = {anananbmbmbm : m, n 0}
3. L = {anbm : mn and m≤10, n 0}
(A) 2 only
(B) 2 & 3 only
(C) 1 only
(D) none of these
Q171. [MSQ]
Q173. [MSQ]
Which of the following languages is/are not regular?
(A) L = {w :na(w)nb(w)}
(B) L = {aibjck : i j+k}
(C) L = {aibjck : j 2i+k}
(D) L ={aibjck : i = j or j k}
Q174. If L1 = {1P : P is a prime number} and L2 = {12𝑖 ∶ 𝑖 ≥ 0} then which of the following
Q175. [MSQ]
Let L1 and L2 are two regular languages over then which of the following is/are
regular?
(A) L = {xΣ* | either xL1 or xL2}
(B) L = {xΣ* | xL1 but xL2}
(C) L = {xΣ* |xyL1 or xyL2; where yΣ*}
(D) L = {xΣ* | xyL1 and |x| = |y|}
Q177. [MSQ]
Which of the following language/s is/are not regular?
(A) L = {aibjck: i+j+k>4}
(B) L = {aibjck: i<10, j>5 and k >i}
(C) L= {aibj: i+2j is a prime number}
(D) L = {aibj : |i – j| = 3}
Q178. [MSQ]
Which of the following language/s is are regular?
(A) L = {aibj : i =j or i<j or i>j}
(B) L = {anbn : n1}U {anbm : n, m 1}
(C) L = {w1w2: w1 = w2 and w1, w2 Σ*}{anbn : n1}
(D) L = {an: n = k3 for some k0}
Q194. Let L1 and L2 are two languages over and it is given that L1.L2 is non-regular
Q195. Let L= 01* + 10*. Which of the following is regular expression of LR (reverse of L)?
(A)0*1 + 1*0
(B) 1*0 + 01*
(C) 1*0 + 0*1
(D) (10)* + (01)*
xyL1} Let L1 = L(a*ba+) and L2 = {aba*} then what will be the L1/L2?
(A)a*
(B)a+
(C)a*b
(D)a+b
Q199. Which of the following strings is NOT in the Kleene closure of the language
(A) a
(B)abd
(C) cd
(D) d
Q201. If L = {001, 1101, 101} then the prefix of L is
(A) {𝜆, 0, 00, 001, 1, 11, 110, 1101, 1, 10, 101}
(B) {𝜆, 0, 00, 001, 1, 11, 110, 1101, 10, 101}
(C) {λ, 1, 01, 001, 101, 1101}
(D) None of the above
Which of the following grammar generates the language accepted by NFA given
above?
(A) S →1S/0A, A→1A/0B/0C, B→0C, C→1B/0C
(B) S →1S/0A, A→1A/0B, B→0C/, C→1B/0C
(C) S →1S/0A, A→1A/0B/0C, B→0C/, C→1B/0C/
(D) S →1S/0A, A→1A/0B/0C, B→0C/, C→1B/0C
Which of the following is a left linear grammar for the language accepted by M?
(A) S 1S0|
(B) S 10S|
(C) S 1A|, A0S
(D)S A0| , AS1
S abA
AbaB
BaA | bb
How many states are required to construct minimized DFA for language accepted by
G?
(A) 2
(B) 3
(C) 4
(D) more than 4
SaA|bB|λ,
AbC|aS,
BaC|Bs
CaB|bA
Which of the following language is generated by G?
(A) L = {w :na(w) + nb(w) is even}
(B) L = {w : |na(w) - nb(w)| is even}
(C) L = {w :na(w) and nb(w) are both even}
(D) L = {w :na(w) and nb(w) are both odd}
S aA|bB
A abA | λ
B ccB | λ
Which of the following regular expression is for language generated by G?
(A)a(ab)*b(cc)*
(B) a(ab)+b(cc)+
(C) a(ab)*+b(cc)*
(D) a(ab)++b(cc)+
S → AaAaAaA,
A → aA|bA|.
(A) All the strings over * with at least three a's.
(B) All the strings over * with at most three a's
(C) All the strings over * with at least three a's or three b's
(D) None of these
For the next two questions: Let Σ1 ={0, 1, 2} and Σ2 = {a, b, c, d}and define h(0) = aab,
h(1)=aabc, h(2) = cccd.
(A) 02*1*0
(B) 02*
(C) 1*0
(D) 02*U 1*0
Q222. [MSQ]
Consider the language L = {aibj | j < i}. Which of the following string can be used in
a pumping lemma proof that L is not regular? [Assume n is pumping length]
(A) anbn
(B) a2nbn
(C) a2n+1b2n
(D) (ab)na
Which of the following are good choices of a string to pick to show that L is not
regular with the help of pumping lemma?
(A) apbbap
(B) ap
(C) bapb
(D) All of the above are good choices of strings
Q225. {anbm : n > m > 0} is
(A) not regular because ap+1bp cannot be pumped
(B) regular because it is a subset of a*b*
(C) not regular because apbp cannot be pumped
(D) regular because it is described by a regular expression
is
(A) regular by closure under union
(B) not regular because it contains 0m1m
(C) regular because you can always pump by setting v to be the leading 1 or 11
(D) not regular because L' is not regular, because 10p1p cannot be pumped in L'
Q227. How many of the following statement is/are false? _________
1. The pumping lemma for regular languages is about proving a language to be
regular.
2. The language {ww : w * with |w| ≥2 } is not regular.
3. The language {w {a +b)* and the number of occurrences of a in w is the same as
that of b in w} is not regular.
4. The language {w {a +b)* : the number of occurrences of ab in w is the same as
that of ba in w} is not regular.
5. Every non-regular language is infinite.
Q13. [MSQ]
Which of the following language is/are context free?
(a) L = {anbn: n 0 and n is neither prime nor composite}
(b) L = {ap | p is prime number or p = 0}. {ap | p is not a prime number}
(c) L = {0i1i0i1i | i is a prime number and 0 < i < 100}
(d) L = {(0n1m)k| m, n >= 0}.
Q15. [MSQ]
Which of the following language is/are context free?
(A) L1= {anbj| n = j2}
(B) L2 = {an| n is multiple of a prime}
(C) L3 = {wwwRwR| w{a}*}
(D) L4 = {ajanbjbn | n = j and n, j >= 0}
Q16. [MSQ]
Which of the following language is/are DCFL?
(A) L = {wxcxR | w {a, b, c}* and x {a, b}* }
(B) L = {xcxRw| w {a, b, c}* and x {a, b}* }
(C) L = {xwxR| w {a, b, c}* and x {a, b}* }
(D) L = {xcxRw| w, x {a, b}*}
Q19. [MSQ]
Let L1 be a context-free language and L2 L1 then which of the following statement
is/are true?
(A) L2 is definitely context-free.
(B) L2 may not be a context-free language.
(C) L1 L2 is definitely context-free.
(D) L1R is context sensitive.
Q20. Let L language collection of strings over {0, 1} containing ten more 0 than 1. These
language is
(A) Regular
(B) Context free but not regular
(C) Recursive but not contexts free
(D) Recursively enumerable but not recursive
Q21. Let L language collection of strings over {0, 1} containing ten more 0 than 1 or
containing ten more 1 than 0. These language is
(A) Regular
(B)Context free but not regular
(C) Recursive but not context free
(D) Recursively enumerable but not recursive
3. {(anb)m|m, n 1}
(A)Only 1&2
(B)Only 2&3
(C)Only 1&3
(D)None
Q23. Consider the following language L = {anbnanbn: n ≥ 0}.Which of the following statement
is true about L?
(A) Regular
(B) Context-free but not regular,
(C) Context-sensitive but not context-free,
(D) Recursively enumerable but not context-sensitive.
Q24. Which of the following languages is/ are not context free?
(i) L = {aibjckdl | i+j = k+l and i, j, k, l N}
(ii) L = {0n#02n#03n | n>=0}
(iii) L = {uawb | u, w {a,b}* and |u| = |w|}
(iv) L = {w ∈ {a, b}* : w has twice as many b's as a's}
(v) L = {amb2nc3ndp: p > m, and m, n ≥ 1}.
(A) iv and v only (B) ii only
(C) ii and v only (D) i, iii, iv, v
Q28. Consider the following language L = {w#z: w is a substring of z and w, z {a, b}*}.
Which of the Following is true about L?
(A) Regular
(B) Context-free but not regular
(C) Context-sensitive but not context-free
(d) Recursively enumerable but not context-sensitive.
Q33. Let L1 = {w: w is palindrome & w {a, b}*} and L2 = {wwR#w : w{a, b}*}, then.
Which of the following statement is not true?
(A) L1 is CFL but L2 is DCFL.
(B) L1 is DCFL but L1 is not DCFL.
(C) Both L1 and L2 are CFL.
(D) L1 is CFL but L2 is not CFL.
Q35. Which of the following languages on 𝛴 = {a, b} is/are not context- free?
(i) L = {aibj| i and j are both prime}
(ii) L = {aibj | i is prime or j is prime}
(iii) L = {aibj | i is prime but j is not prime}
(iv) L = {aibj | neither i is prime nor j is prime}
(A) i, ii only (B)iii, iv only
(C)ii, iv only (D) All the above
Q43. [MSQ]
Which of the following grammars have more than one parse tree for the string ‘1001’?
(a) (b) (c) (d)
S XY S XY S 0S | 1S | SS S 1S0S
X 0X | 1X | λ X 0X1 | 1X0|λ S0|1 S 0S1S
Y1Y1 | 0Y0 | Y1Y| 0Y |λ S λ
λ
Q46. Which of the parse trees below yield the same word?
Q48. The parse tree below represents a rightmost derivation according to the grammar
S → ABS|AB|aA, A → aS|a, B → bA
Q50. Consider the grammar (with start variable S and terminals a and c).
S SaS | cS | cc
Which of following parse trees matches the grammar?
(A) i ,iii,iv
(B)iii,iv
(C)ii
(D)i and iv
Q52. Given the simple CFG with non-terminals {S,A,B}, terminals {a,b}, and productions
S → AB, A → AB | a, B → BA | b.
Which of the following derivation is NOT a derivation of the string abab?
(A) S ⇒ AB ⇒ Ab ⇒ABb ⇒ ABAb ⇒ AbAb ⇒ Abab ⇒ abab
(B) S ⇒ AB ⇒ ABB ⇒ ABAB ⇒ aBaB ⇒ abab
(C) S ⇒ AB ⇒ ABA ⇒ ABAB ⇒ ABAb ⇒ AbAb ⇒ Abab ⇒ abab
(D) S ⇒ AB ⇒ aB ⇒ aBA ⇒ abA ⇒ abAB ⇒ abaB ⇒ abab
Q59. Consider three language L1, L2, L3 and three grammar G1, G2, G3:
L1 = {aibjck | k = i +2*j}
L2 ={aibick | k>=3},
L3 = {aibjck | k = i +j}
Q61. Let V = {S}, = {a, b}. Which of the following grammars is such that the language
Generated by it is {wwr : w{a, b}*}.
(A) G1 = (V, , R1, S), where R1 = {(S→aSa), (S→bSb), (S→)}
(B)G2 = (V, , R2, S), where R2={(S→aSa), (S→bSb), (S→a), (S→b), (S→)}
(C) G3 = (V, , R3, S), where R3 = {(S→Sa), (S→Sb), (S→)}
(D) G4 = (V, , R3, S), where R3 = {(S→aSb), (S→)}
Q62. Which of the following CFG generates all the strings contains more 1’s than 0’s?
(A)S → 0T | 11T T → 0S | 11S |
(B)S → 0S1 | 1S0 | 1S1 | 1
(C) S → TS | 1T | 1S T → TT | 0T1 | 1T0 |
(D) S → TS | 1T | 11 T → TT | 0T1 | 1T0 | 1
Q65. Consider the pushdown automaton with the following transition rules:
δ(q,0,Z0) = {(q,XZ0)}
δ(q,0,X) = {(q,XX)}
δ(q,1,X) = {(q,X)}
δ(q,ε,X) = {(p,ε)}
δ(p,ε,X) = {(p,ε)}
δ(p,1,X) = {(p,XX)}
δ(p,1,Z0) = {(p,ε)}
The start state is q. For which of the following inputs can the PDA first enter state p with
the input empty and the stack containing XXZ0 [i.e., the ID (p,ε,XXZ0)]?
(A) 001111 (B) 0101010
(C) 001110 (D)111001
Q67. Consider the pushdown automaton with the following transition rules:
δ(q,0,Z0) = {(q,XZ0)} ; δ(q,0,X) = {(q,XX)} ; δ(q,1,X) = {(q,X)}
δ(q,ε,X) = {(p,ε)}
δ(p,ε,X) = {(p,ε)}
δ(p,1,X) = {(p,XX)}
δ(p,1,Z0) = {(p,ε)}
From the (p, 1101, XXZ0), which of the following states can NOT be reached?
(A) (p,101,XXZ0)
(B) (p,1101,XZ0)
(C) (p,ε,XZ0)
(D)(p,101,XXXZ0)
(A){aibj| 0≤ 𝑗 ≤ 𝑖} (B){aibj| 0≤ 𝑖 ≤ 𝑗}
(C){anbn| n≥ 0} (D){(ab)n | n≥ 0}
(A){aibjck | i + k = j}
(B) {aibjck | i<j=k }
(C) {aibjci | i=j }
(D) {aibjck | i<j and k>0}
(A){aicjbi | i,j≥ 0}
(B) {aicjbk | i, j, 𝑘 ≥ 0}
(C) {aicjbi | i, j> 0}
(D) {aibi | i≥ 0}
(A)L(G)={a2nb2n, n≥ 1}
(B)L(G)={a2n+1b2n+1, n≥ 1}
(C)L(G)={a2nb2n, n≥ 0}
(D)L(G)={a2n+1b2n+1, n≥ 0}
Q75. Consider the following PDA
(A) L = {aibjck | i= j or j = k}
(B) L = {aibjck | i = j and j = k}
(C) L = {aibjck | i= j + k}
(D) L = {aibjck | j = i + k}
(A) L = {aibj | i= j}
(B) L = {aibj | i = 2*j}
(C) L = {aibj | i= j and i =2*j}
(D) L = {aibj | i ≤ j ≤ 2i}
Q78. The language accepted by following automata is
(A) set of all strings over {0, 1} which contain at most three 1’s
(B) set of all strings over {0, 1} which contain exactly three 1’s
(C) set of all strings over {0, 1} which contain at least three 1’s
(D) set of all strings over {0, 1}
Q79. Consider the following PDA
Q94. Consider the CFL L1 = {anbmcm | m,n >0 }. Choose a context-free language L2 that
ensures that L1 L2 is not context free?
(A) L2 = {anbmcn | n,m > 0} (B) L2 = {a}* U {b}* U {c}
(C) L2 = {a,b}*L1 (D) L2 = {anbncn | n > 0}
Q101. Let L1 = {w | w* and w = wr, = {a, b}} and L2= a*b*a* . Then L1 L2=
(A) 0 (B) 1
(C) 2 (D) infinite
Q103. Let L be a language. Then symmetric (L) = {w: w ∈ L and wr∈ L}.
Which of the following two statements is/are true?
S1: If L is regular, symmetric (L) is also regular.
S2: If L is context-free, symmetric (L) is also context-free.
(A) Only S1 (B) Only S2
(C) both S1 and S2 (D) Neither S1 nor S2
Q104. Let L1 = {anbncp |n, p≥0} and L2 = {ambncn| m, n≥0} then ̅̅̅̅̅̅̅̅̅̅̅̅̅
(𝐿1 𝑈 𝐿2) will be
(A)
(B) a*b*c*
(C) anbncn
(D) {* - a*b*c*} {ai bj ck | 𝑖 ≠ 𝑗 𝑎𝑛𝑑 j ≠ 𝑘}
Q106. Let L1 = {w1w2 : |w1| = |w2| w1 (a, b)* and w2 (c, d)*} and L2 = {a, c}*.
L1 L2 = Then L1 U L2 is
(A) Necessarily context-free (B) Necessarily non-context-free
(C) May or may not be context-free (D)None of above
Q109. Select the correct statement (Assume that L1, L2, L3 are TM acceptable)
(I) For any languages L1, L2 and L3, L1(L2 L3) (L1L2) (L1L3)
(II) For any languages L1, L2 and L3, (L1L2) (L1L3) L1(L2 L3).
(A)only I (B)only II
(C)Both I&II (D)None of them
Q110. Let A and B be two languages over {0,1} such that A is a subset of B. Consider the
following statements:
(1) If B is finite, then A is finite.
(2) If B is context-free, A is context-free.
(3) If the complement of B is context-free, then the complement of A is context-free.
Which of the above statements is true?
(A) 1 only (B) 1 and 2 only
(C) 1 and 3 only (D) 2 and 3 only
Q113. Consider the set of grammars in which every rule that has two symbols on the RHS
Must have exactly one variable and one terminal. These grammars can generates
(A) It generates all regular languages but no others.
(B) It generates some languages that are not context-free.
(C) It generates all regular languages and some others, but not all of the CFLs.
(D) It can generates all CFLs
Q121. Which of the following statement is /are true for an arbitrary context free language?
(i) Every context-free language A is regular.
(ii) Every context-free language is recursive enumerable.
(iii) Every context-free language is recursively enumerable but not recursive.
(iv) Every context-free language is recursive.
(A) ii and iv only (B) i, ii and iv only
(C) ii and iii only (D)None
Grammar to PDA,
Q122. Consider the following grammar G:
S aSb | aSbb | ab
Suppose you want to construct PDA M (Q, Σ, , 𝛿, z, F) for language generated by
given grammar G.
M is defined by Q = {q0, q1, qf}, Σ = {a, b} = {𝑆, 𝐴, 𝐵, 𝑧}, F = {qf} and 𝛿 is not known.
Which of the following is correct transition rule (𝛿) for M?
(a) 𝛿 (q0, λ, S) = {(q1, Sz)}, 𝛿 (q1, a, S) = {(q1, SB), (q1, SBB), (q1, B)}, 𝛿 (q1, b, B)=
(b) 𝛿 (q0, λ, S) = {(q1, Sz)}, 𝛿 (q1, a, S) = {(q1, SB), (q1, SBB), (q1, B)}, 𝛿 (q1, b, B) =
(c) 𝛿 (q0, λ, S) = {(q1, Sz)}, 𝛿 (q1, a, S) = {(q1, SB), (q1, SBB)}, 𝛿 (q1, b, B) = {(q1, λ)},
s aA | bBC | cC
Aa
B bB | b
C cC | d
(B) 𝛿 (𝑞0 , 𝜆, 𝑧) = {(q1 , Sz)}, 𝛿 (𝑞1 , 𝜆, 𝑆) = {(𝑞1 , aA), (𝑞1 , bBC), (𝑞1 , cC)},
(C) 𝛿 (𝑞0 , 𝜆, 𝑧) = {(q1 , Sz)}, 𝛿 (𝑞1 , 𝜆, 𝑆) = {(𝑞1 , aA), (𝑞1 , bBC), (𝑞1 , cC)},
Q126. [MSQ]
Which of the following grammar is/are equivalent to G?
(a) S aA, A aAbc | bb | a
(b) S aA, A aABc | bB | a, Bb
(c) S aA, A aABC | bB | a, B b, Cc
(d) S aS | aSbc | bb | a
(A) G1 and G2
(B) G2 and G3
(C) G3 and G4
(D) G4 and G1
Q139. Which of the above grammars is in Greibach Normal Form?
(A) G1
(B) G1 andG2
(C) G3
(D) G4
Q140. Which of the above grammars is in Chomsky Normal Form?
(A)G1
(B) G2
(C) G3
(D) G4
S→abSb|bSaa|aa
Which of the following grammar are in GNF and equivalent to G?
(A)S→aBSb | bSAA | aA, A→a,B→b
(B)S→aBSb | bSAa | aA, A→a, B→b
(C)S→aBSB | bSAA | A, A→aa, B→b
(D) S→aBSB | bSAA | aA, A→a, B→b
CYK Algorithm
For next four questions: Consider the following grammar G:
S AB | BC
A BA | a
B CC | b
C AB | a
We are applying CYK algorithm for the string ‘baaba’ and given grammar G. The incomplete
triangular table is shown below:
Q148. Let L be a context free language and w = uvxyz is any string in L such that |𝑤| ≥ 𝑚;
where m is some constant positive integer then which of the following conditions must
be satisfied in order to apply pumping lemma?
(i) |𝑣𝑥𝑦| ≤ 𝑚
(ii) vy ≠ 𝜀
(iii)|𝑣𝑥𝑦| ≥ 𝑚
(iv) vy = 𝜀
(A) i and ii only
(B) iii and iv only
(C) i and iv only
(D) ii and iii only
(I) Since the pumping lemma applies to all context-free languages, all context-free
languages contain an infinite number of strings.
(II) The stack alphabet of pushdown automata must be the same as the input alphabet.
(III) The stack alphabet of pushdown automata must be different from the input
alphabet.
(IV) If a language L satisfies the conditions stated in the pumping lemma for CFLs, then
L is context free.
(A) Only I&II (B) Only I & III
(C) Only III&IV (D)None of above
Decidability of CFL & CFG
Q152. Which of the following is/are decidable properties of context free?
(A)a* (B)a*ba*
(C)ba* (D)aba*
M2 = ({q0, q1, qaccept, qreject}, {0, 1}, {0, 1, #,}, δ, q0, qaccept, qreject)
δ(q0, 0) = (qaccept, 0, R)
δ(q0, 1) = (q1, 1, R)
δ(q0, #) = (qreject, 1, R)
δ(q0,) = (qreject, 1, R).
δ(q1, 0) = (q1, #, R)
δ(q1, 1) = (q1, #, R)
δ(q1, #) = (q1, #, R)
δ(q1,) = (q1, #, R)
(A) halts on all the string starts with 0
(B) does not halts on
(C) halts on all the string starts with 1
(D) does not halts on any string.
Data for next two questions: Consider the following TM
Q14. Determine what the Turing machine does when presented with the “aaabbbb”.
(A) TM halt at final state
(B) TM does not halt and loop forever
(C) TM reject the input
(D) Cannot say about this input
Q15. Determine what the Turing machine does when presented with the “aaaaabbbbb”.
(A) TM halt at final state
(B) TM does not halt and loop forever
(C) TM reject the input
(D) Cannot say about this input
Q16. Is there any input for which the Turing machine goes into an infinite loop?
(A) No.
(B) Yes, there is an input “abb” for which the Turing machine goes into an infinite loop.
(C) Yes, there is an input “aaaaaabbbbbbbbbb” for which the Turing machine goes into
an infinite loop.
(D) None of the above.
Q18. What is the smallest number of tape symbols that a TM with nonempty input alphabet
could have?
(A) 0 (B) 1
(C) 2 (D) 3
(A) {ak bk ck | k ≥ 0}
(B) {ai bj ck | i, j, k ≥ 0 and i = k}
(C) {ai bj ck | i, j, k ≥ 0 and i = k or j = k}
(D) {ai bj ck | i, j, k ≥ 0 & i = k and j = k}
Q24. Construct following Turing machine with input alphabet {a, b},
L1 = {<M>|M is a TM, and M accepts (at least) two strings of different lengths} is:
(A) Recursive
(B) Recursively enumerable but not recursive
(C) Not recursively enumerable
(D) Not recursive
Q33. Let the language 𝐴 𝑇𝑀 ={<M,w> | M is a TM that accepts string w} then the complement
of the language is
(A) Decidable
(B) Turing Recognizable
(C) Not Turing Recognizable
(D) None
Q35. Then L2 is
(A) Recursive (B) RE (C) Not RE (D) finite
Q36. Then L3 is
(A) Recursive (B) RE (C) Not RE (D) finite
Q37. Then L4 is
(A) Recursive (B) RE (C) Not RE (D) finite
Q38. Then L5 is
(A) Recursive (B) RE (C) Not RE (D) finite
Q39. Then L6 is
(A) Recursive (B) RE (C) Not RE (D) finite
Q40. Then L7 is
(A) Recursive (B) RE (C) Not RE (D) finite
Q41. Then L8 is
(A) Recursive (B) RE (C) Not RE (D) Co-RE
Q42. Then L9 is
(A) Recursive (B) RE (C) Not RE (D) Co-RE
Q43. Then L10 is
Q47. EQTM = {<M1, M2> | M1, M2 are TMs with L(M1) = L(M2)}?
(A) Decidable (B) Turing Recognizable
(C) Not Turing Recognizable (D) None
Q50. Which of the following statements is true for every language L ⊆ {0, 1}*?
1. L is non-empty.
2. L is decidable or L is infinite (or both).
3. L is accepted by some DFA with 42 states if and only if L is accepted by some NFA
with 42 states.
4. L is decidable if and only if its complement L is undecidable.
(A) 1 and 4 Only (B) 2 and 3 Only
(C) 2 Only (D) 1, 2, 3 Only
1. M moves its head to the right at least once, given input 0101.
2. M never accepts before reading a blank.
3. For some input string, M moves its head to the left at least once.
4. For some input string, M changes at least one symbol on the tape.
(A) 2, 3 & 4
(B) 3 & 4
(C) 1 & 2
(D) All
Q53. Which of the following problems about Turing machines is/are undecidable?
1. To determine, given a Turing machine M, a state q, and a string w, whether M ever
reaches state q when started with input w from its initial state.
2. To determine, given a Turing machine M and a string w, whether M ever moves its
head to the left when started with input w.
3. To determine, given Turing machine M and a string w, whether w is accepted by M
within some given time constraint T.
4. To determine, given a Turing machine M, and a string w, whether M ever halt for
input w.
(A) 1 & 2 only
(B) 2 and 4 only
(C) 1, 2 & 4 only
(D) all are undecidable
Q60. Consider a Turing machine which can move only left, at most 5 times in the course of
computation on any input. Consider all TMs that have this property. What languages do
they recognize?
(A) Exactly the regular languages.
(B) Exactly the context-free languages.
(C) Exactly the decidable languages.
(D) Exactly the recognizable languages
Q61. Select all the statements that are TRUE. The class of recursively enumerable languages :
1. Not closed under union
2. Closed under intersection
3. Closed under complement
4. Not closed under Kleen's star
5. Not closed under infinite union
(A) 1, 2 and 4 only (B) 3 and 5 only
(C) 2 and 5 only (D) 1and 4 only
Q66. Consider an arbitrary language L ⊆ {0, 1}∗ . Which of the following statements must be
true?
i) If L is decidable, then L is infinite.
ii) If L is not decidable, then L is infinite.
iii) If L is the union of two regular languages, then its complement L is context-free.
iv) If L is context-free, then its complement L is context-free.
v) If L is finite, then L is context-free.
(A) iii and v only (B)i and ii only
(C)ii, iv and v only (D)ii, iii and v only
i) For every recursive language L, there is a Turing machine M with 𝐿̅ as its language.
ii) For every non-deterministic push-down automaton, there is an equivalent
deterministic push-down automaton.
iii) Non-deterministic Turing machines are strictly more powerful than Deterministic
Turing machines.
(A) i only
(B) ii only
(C) iii only
(D) i and iii only
For next five questions: Let L1 and L2 be languages in the respective language class, and let R
be a regular language, and x be a given word over alphabet. Some problems are given in the
questions identify the classes of languages for which the problem is decidable
Q82. If S1 and S2 are countable set, then how many of the following statement is/are true?
1. S1 S2 is countable. 2. S1 S2 is countable.
3. S1 S2 is countable. 4. S1 - S2 is countable.
Decidability/Undecidability
• Every question we’ve asked about the language of finite automata is decidable
Is w L(M)?, Is L(M)= , Is L(M)= finite , Is L(M)= *