0% found this document useful (0 votes)
17 views120 pages

TOC - Basic Final

Uploaded by

as5626531
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views120 pages

TOC - Basic Final

Uploaded by

as5626531
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 120

REGULAR LANGUAGE

Q1. Consider the follwing grammar G:


SaSa |
aAa
ABb
Bc
The grammar G belongs to which type of Chomsky classification?
(A) Type 3
(B) Type 2 but not type 3
(C) Type 1 but not type 2
(D) Type 0 but not type 1
Q2. Consider the following grammar G with start symbol S
Sa SC| T
TbTd|R
dCCd
RCCr
R

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

BASIC THEORY OF COMPUTATION Page 1


Q4. What is the highest type number that can be assigned to the following grammar?
S → aA | bB
A → aB | bC
B → aB | bB
C → aC | bC | λ
(A) Type 0
(B) Type 1
(C) Type 2
(D) Type 3
Q5. Consider the following grammar G with starting symbol S:
S → bTbb
T → bTbb | Acccb
A → aAc | λ
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
Q6. The following grammar
G = (N, T, P, S)
N = {S, A, B, C, D, E}
T = {a, b, c}
P : S → aAB
AB → CD
CD → CE
C → aC
C → b
bE → bc is
(A)is type 3
(B) is type 2 but not type 3
(C)is type 1 but not type 2
(D) is type 0 but not type 1

BASIC THEORY OF COMPUTATION Page 2


Q7. The following grammar
G = (N, T, P, S)
N = {S, A, B, C, D, E}
T = (a, b, c}
P : S → ABCD
BCD → DE
D → aD
D → a
E → bE
E → c is
(A) is type 3
(B) is type 2 but not type 3
(C) is type 1 but not type 2
(D) is type 0 but not type 1
Q8. A grammar has the following productions:
S  aSSb | a | bSa
Which of the following sentences are in the language that is generated by this
grammar?
(A) aaaaabb
(B) aabbaabb
(C) bbbaabbaa
(D) All of the answers above are correct
Q9. Consider the grammar below, with start symbol S.
S  AS | SB | 
A  Aa | a
B  Bb | b
Which of the following strings can’t be generated by this grammar?
(A) a
(B) abb
(C) abba
(D) aaabbb

BASIC THEORY OF COMPUTATION Page 3


Q10. Consider the following grammar G:
S→AB |aB A→aab| λ B→bbA
If the language accepted by G is L(G) then which of the following set of string is the
subset of the L(G)?
(A) {bbaa, abb, bb}
(B) {bbaa, bba, abb}
(C) {aab, abb}
(D) None of these

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) ) ( ( ) ( )

BASIC THEORY OF COMPUTATION Page 4


Q14. Consider the following grammar G:
S → AB
A → 0A1 | 2
B → 1B | 3A
Which of the following strings are in L (G)?
i) 021300211
ii) 002111300211
iii) 00211100211
iv) 0021113002111
(A)i and ii
(B)iii only
(C)iii and iv
(D)i,ii and iv

Q15. A grammar is described as follow:


SaS
S  b
S bA
A bB
B  a
Which of the following strings cannot be derived from the above grammar?
(A) abba
(B) abbb
(C) bba
(D) aab

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

BASIC THEORY OF COMPUTATION Page 5


Q17. Consider the grammar given below
S →xB | yA
A → x | xS | yAA
B → y | yS | xBB
Consider the following strings.
i. xxyyyxyxyxy
ii. yyxxyyxx
iii. yxxyxyxy
iv.xxyyxy
Which of the above strings are generated by the grammar?
(A) i and ii only (B) ii , iii and iv only
(C) i, ii and iii only (D) All the above

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 }

BASIC THEORY OF COMPUTATION Page 6


Q20. Consider the following grammar
S → aSc | X
X → bXc | 
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+ k }
(C) { aibjck | i, j, k ≥ 0, and k= i- j }
(D) None of the above

Q21. Consider the following language


S -> AX | Y C
A  aA |
C  cC | |
X  bXc | |
Y aY b ||
L(G) is
(A) L(a*b*c*)
(B) {anbncn | n >= 0}
(C) {aibjck | i = j or j = k}
(D) none of the above
Q22. What is the language of the grammar with the following production rules?
S ASb | c Aa
(A) {ancbn | n  N}
(B) {xcb | x {a}*}
(C) {acy | y  {b}*}
(D) All of the answers above are incorrect
Q23. Which language generates the grammar G given by the productions?
S → aSa | aBa B → bB | b
(A) L(G) = { anbman | n > 0, m > 0}.
(B) L(G) = { anbman | n > 0, m < 0}.
(C) L(G) = { banb | n > 0, m > 0}.
(D) None of these

BASIC THEORY OF COMPUTATION Page 7


Q24. Consider the following grammar G:
S → aSbb|
The language generated by the above grammar is:
(A)L={anbn:n≥0}
(B)L={anb2n:n≥0}
(C) L={ambn:n≥0}
(D)None
Q25. The language generated by the following grammar is:
S  0S1 | C C  1C0 | 
(A) L1 = {0n1m0m1n | n, m ≥0}
(B) L1 = {0m12n0n1n | n, m ≥ 0}
(C) L1 = {0n1m02m1n | n, m ≥ 0}
(D) L={0n1n1m0m |n, m ≥ 0}
Q26. Consider the following grammar G with start symbol S over the alphabet Σ = {a, b}
S → aSaa | B
B → bB | λ
The language generated by G is
L1 = {anbna2m |n, m ≥ 0}
L2 = {anb2m |n, m ≥ 0}
L3 = {anbma2n |n, m ≥ 0}
L4 = {anbma2m |n, m ≥ 0}
(A)L1 (B) L2
(C)L3 (D)L4

Q27. Consider the following language:


L = {akb2k | k >=2}
Which of the following grammar generates L?
(A) S  aSbb | λ
(B) S  aSbb | abb
(C) S  aSbb | aabbbb
(D) S  aX | bbY X  aX | λ Y  bbY | λ

BASIC THEORY OF COMPUTATION Page 8


Q28. Consider the following language:
L = {abn | n >= 0}  {(ba)m | m > = 0}
(A) S  abS | baS | λ
(B) S  aX | bY X  bX | λ Y  baY | λ
(C) S  aX | baY X  bX | λ Y  baY | λ
(D) None of the above

Q29. Consider the Grammar G, with productions.


SaA | , AbS
Which of the following language are generated by G?
(A) L = {anbn|n>0}
(B) L = {anbm| n>0, b>0}
(C) L = {(ab)n | n≥0}
(D) L = {(ab)n |n>0

Q30. Which language generates the grammar G given by the productions


S → aSdd | A
A → bAc | bc
(A) L(G) = { an bmcm d2n | n 0, m >0}
(B) L(G) = { ambmcnd2n | n 0, m >0}
(C) L(G) = {aibmcm d2n |i>0, n 0, m >0}
(D) L(G) = { an bicjd2n | n 0, i>0, j > 0}

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.

BASIC THEORY OF COMPUTATION Page 9


Q32. The language generated by the following grammar is
S→ aB| bA
A→ a|aS|bAA
B→ b|bS|aBB
(A) Strings contain equal number of a's and equal number of b's.
(B)Strings contain odd number of a's and odd number of b's.
(C)Strings contain odd number of a's and even number of b's.
(D)Strings contain even number of a's and even number of b's.

Q33. Consider the following grammar


S → 0S0 | 0S1 | 1S0 | 1S1 | 0
What is the language generated by this grammar?
(A){w  {0, 1}* | the length of w is odd }
(B){w  {0, 1}* | the length of w is odd and the middle symbol is 0 }
(C){w  {0, 1}* | the length of w is odd and the middle symbol is 1 }
(D){w  {0, 1}* | w contains 0 in middle }

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.

Q35. How many of the following is/are true? _________


(i) baa a*b*a*b*
(ii) b*a*  a*b* = a*  b*
(iii) a*b*  c*d* = 
(iv) abcd  (a(cd)*b)*

BASIC THEORY OF COMPUTATION Page 10


Q36. Determine whether the strings in the table belong to any of the languages described
by the following regular expressions

(i) For 1001 : T, F, F, F, F


(ii) For 110 : F, F, F, F, T
(a) i only (b) ii only (c) Both i & ii (d) Neither i nor ii

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

BASIC THEORY OF COMPUTATION Page 11


Q40. Someone has asserted that the following two regular expressions describe the same
language: R1 = ((ab*a) + (ba*b))* and R2 = ((ab*a) + b*)*. Which of the following
strings is contained in one of the languages but not in the other?
(A) ababab (B) bbbbbb
(C) abba (D) bbabba

Q41. The regular expression b*ab*ab*ab* represents the language


(A) L = {w : w  *, na(w) = 3}
(B) L = {w : w  * na(w) <=3}
(C) L = {w : w  * na(w) >= 3 }
(D) none

Q42. The regular expression b* + b*ab*+ b*ab*ab* represents the language


(A) L = {w : w  *, na(w) = 2}
(B) L = {w : w  * na(w) <=2}
(C) L = {w : w  * na(w) >= 2 }
(D) none
Q43. Which of the following pair of regular expression is/are true?
I. (01 +0)*0  0(10 +0)* II. 0(120)*12 01(201)*2
III. *  λ* IV. (0*1*)*  (1*0*)*
(A) I, III and IV only (B) II and III only
(C) II, III and IV only (D) All the above

Q44. Regular expression r = (aa*b)* (aa* + ) is equivalent to:


(I) (ab)* (a+)
(II) a*(ab)*
(III) (b+ba)*
(IV) (a+ab)*
(V) (aa*b)*
(A) IV and V
(B) I, II and III
(C) II, IV and V
(D) IV only

BASIC THEORY OF COMPUTATION Page 12


Q45. Identify the pairs of regular expressions that are equivalent (in that they describe
the same sets of strings):
(I) (ab)+ (ab)*ab
(II) ab* (ab)*
(III) (a|b+) (a|(b)+)
(IV) a+* a+
(V) a*a (ba*a)* (a + ab)*a.
(A)I, II and III only
(B)I and III only
(C)I, III and V only
(D)All are equivalent
Q46. Match the regular expression with its description
(1) (0∪1)*01(0∪1)* i. All strings which doesn’t contain the substring 101.
(2) 1*0* ii. Strings containing the substring 01.
(3) (10∪0)*(1∪10)* iii. Strings of the form 111 . . . 000 . . ., that is, strings that
begins with Zero or more ones followed by zero or more
zeroes
(4) 0*(1∪000*)*0* iv. All strings where each occurrence of 00 precedes all
Occurrences of 11
(A) 1-ii,2-iii,3-i,4-iv
(B) 1-ii,2-iii,3-iv,4-I
(C) 1-iv,2-iii,3-ii,4-i
(D) 1-iii,2-ii,3-i,4-iv

Q47. How many of the following is/are true? __________


(i) (ab)*a = a(ba)*
(ii) (a b)* b (a  b)* = a* b (a  b)*
(iii) [(a  b)* b (a  b)*  (a  b)* a (a  b)*] = (a  b)*
(iv) [(a  b)* b (a  b)*  (a  b)* a (a  b)*] = (a  b)+
(v) [(a  b)* b a (a  b)*  a*b*] = (a  b)*

BASIC THEORY OF COMPUTATION Page 13


Q48. [MSQ]
Which of the following regular expressions are equivalent to the regular expression
R = (bba + aab + ab + b + a)+ + λ
(A)(a*b*)* (B)(a*b*)+ + λ
(C)(a + b + aa)* (D) (a + b)*
Q49. [MSQ]
Which of the following regular expression is equivalent to given regular expression:
ε+1*(011) *(1*(011) *) *
(A) (1+011) * (B) (1*(011) *)
(C) (1+(011) *) * (D) (1011) *
Q50. If r and s are regular expressions, write r ≤s to mean that the language of strings
matching r is contained in the language of strings matching s. Then which of the
following is/ are true?
(i) r*|s*≤(r|s)*
(ii) (r|s)*≤r*|s*
(iii)(r*s*)*≤ (r|s)*
(iv) (r|s)*≤(r*s*)*
(v) (rs|r)*r≤r(sr|r)*
(A) i, ii, iii only
(B)i, iii, iv only
(C)ii, iii, iv only
(D) All except ii

Q51. Which of the following is true?


(i) (01)*0 = 0(10)*
(ii)(0+1)*0(0+1)*1(0+1) = (0+1)*01(0+1)*
(iii) (0+1)*01(0+1)*+1*0* = (0+1)*
(iv) (0(0+1)*1 + 1(0 + 01)*0)* = (01 + 10)*
(A) i only
(B) i and iii only
(C) i, ii and iii only
(D) All the above

BASIC THEORY OF COMPUTATION Page 14


Q52. Consider the following four regular expressions over the alphabet {a, b}:
E1 = (ab + a*b*b*)*
E2 = ((ab)* (a*b*b*)*)*
E3 = (a + b)*
E4 = a(a + b)*
Which of the following statements is true?
(A) L(E2) = L(E3)
(B) L(E3) = L(E4)
(C) L(E1) = L(E4)
(D) L(E2) = L(E4)
Q53. What will be the regular expression for language L = {xwx : x, w  {0, 1}*, |x|≤3}?
(A) (0+1)3 (0 + 1)*(0+1)3
(B) ((0+1)+(0+1)2+(0+1)3) (0 + 1)* ((0+1)+(0+1)2+(0+1)3)
(C) (λ + (0+1)+(0+1)2+(0+1)3) (0 + 1)*(λ + (0+1)+(0+1)2+(0+1)3)
(D) None of these
Q54. What will be the regular expression for the following language
L1 = {pwp: p, w {0, 1}*, |p|=7, kI+}?
(A) (0+1)7 (0 + 1)*(0+1)7
(B) ((0+1)+(0+1)2+(0+1)3 +… +(0+1)7) (0 + 1)* ((0+1)+(0+1)2+(0+1)3+… +(0+1)7)
(C) (λ + (0+1)+(0+1)2+(0+1)3+… +(0+1)7) (0 + 1)*(λ + (0+1)+(0+1)2+(0+1)3+… +(0+1)7)
(D) Both a and b
Q55. The regular expression (a + b)*a(a + b)* represents the language
(A) Contains exactly 1 a
(B) Contains at least 1 a
(C) Contains at most 1 a
(D) none
Q56. The regular expression (b*ab*ab*)* represents the language
(A) L = {w : w  *, na(w) is divisible of 2 }
(B) every b is followed by at least one a
(C) L = {w : w  * na(w) >= 2 }
(D) None of these.

BASIC THEORY OF COMPUTATION Page 15


Q57. Which of the following regular expressions generate all the strings with even
Numbers of 0?
(i)1*(00)*1*
(ii) 1*(010)*1* .
(iii) (1*01*01*)*
(iv) 1*(01*0)*1*
(A)iii and iv only (B)ii, iii and iv only
(C)iv only (D)iii only
Q58. Which of the following expression best describes the language L = {{0, 1}* | 
contains 1’s only}
(A) 1* (B) 1+
(C) 0 + 1* (D) 1.(1)+
Q59. Which of the following expression best describes the language
L = {{0, 1}* |  contains only 0’s or only 1’s}
(A) 0* + 1* (B) (00+) + (11+)
(C) 0+ + 1+ (D) 0(0 + 1)*1

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

BASIC THEORY OF COMPUTATION Page 16


Q63. Let  = {0, 1}, and language over, L = {*|  does not contain 11}. Which of the
Following regular expression best describes the given language?
(A) 0*(10)* (B) 0*(10+)* (1+)
(C) (0*10*10*)* (D) (0+10)*
Q64. Which of the following regular expression generate all the strings with odd numbers
of 1?
(A) 0*10*(10*1)* (B) 0*10*(10*1)*0*
(C) 0*10*(101)*0* (D) 0*(10*10*1)*0*
Q65. Which of the following regular expressions define the same language?
(1) (ab)*
(2) (aa*b)* a*
(3) a*b*
(4) a* (aba*)*
(A) 1 and 3 only
(B) 2 and 4 only
(C) 3 and 4 only
(D) All define different languages

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

BASIC THEORY OF COMPUTATION Page 17


Q68. Which of the following statement is / are correct?
I. (a* b*) a b c ≡ (a | b )* a b c

II. (a*b*)*a b c ≡ (aa + ba + a*b + (bb)*a)* a b c

(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.

Q71. Which of the following languages denoted by the regular expressions


R = 0*10*10*10*
(A) strings from the alphabet {0, 1} in which there are an odd number of 1s
(B) strings from the alphabet {0, 1} in which ones never appear together
(C) strings from the alphabet {0, 1} in which there are exactly three ones.
(D) strings from the alphabet {0, 1} in which there are exactly three ones or no ones

BASIC THEORY OF COMPUTATION Page 18


Q72. How many of the regular expression(s) which matches all strings of 0’s and 1’s that
do not contain the substring 011? ____________
(1) ((011)0*1*)* (2) (0*1)+0* + 1*0*
(3) (01|010|100|110)* (4) (0+1)*0*|1*0*

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)*

Q79. Consider the following grammar G:


S →AabB, A→ b | bA | λ, B → aB | aa | λ
Which of the following regular expression is equivalent to the language generated
by G?
(A) b*abaa*
(B) a*abb*
(C) b*aba*
(D) b+aba+

BASIC THEORY OF COMPUTATION Page 19


Q80. Consider the following grammar G:
S →AB | aAb A→ b | baA | λ B → aB | abB | λ
Which of the following regular expression is equivalent to the language generated
by G?
(A) (ba)*(b + λ)(a + b)*
(B) (ba)*(b + λ)(a + ab)*
(C) (ba)*(b + λ)(a + ab)* + a (b + ab)*b
(D) a((ba)*(b + λ))b + (ba)*(b + λ)(a + 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 | λ YbaYbbY | λ
(B) S  aX | Ya X  aX | a YbaY | bbY | λ
(C) S  aaX | Ya X  aX | a YbaY | bbY | λ
(D) None of the above

Q83. Which of following Grammar generates the language L(a*a(a+ba)*)?


(A) S S1|S2, S1aA, AaA|, S2aS2|baS2 |
(B) S S1S2|S1, S1aA, AaA|, S2aS2|baS2|
(C) S S1S2|a, S1aA, AaA|a, S2aS2|baS2 |
(D) Both B and C

BASIC THEORY OF COMPUTATION Page 20


Q84. Which of the following grammars is a right regular grammar with the same language
as the regular expression (a* b*)  (a*b*)?
(A) S → AB A → aA | ε B → bB | ε
(B) S → A | B A→ Aa | ε B → Bb | ε
(C) S → A | B A → aA | a B → Bb | a
(D) S → A | B A → aA | ε B → bB | a
Q85. Consider the following NFA

Which of the following string is not accepted by the following NFA?


(A) 00000000 (B) 01001
(C) 111110010 (D) None
Q86. Which of the following string is accepted by given DFA?

(A) aaabbbbbb (B) aababb


(C) abab (D) babaa
Q87. Consider the following DFA:

If the input is 011100101, which edge of the automaton is NOT traversed?


(A) CD
(B) AC
(C) BC
(D) BD

BASIC THEORY OF COMPUTATION Page 21


Q88. Consider the following DFA:

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

BASIC THEORY OF COMPUTATION Page 22


Q91. What is the complement of the language accepted by the following NFA? ( = {a})

(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.

BASIC THEORY OF COMPUTATION Page 23


Q94. [MSQ]
If L (D) = L(D1) ∪ L(D2), then which of the following regular expression is/are
equivalent to L(D)?
(A) (0 + 1)* (B) (01 + 10)(0 + 1)*
(C) (0*1 + 1*0) (0 + 1)* (D) (0 + 1)+

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

BASIC THEORY OF COMPUTATION Page 24


Q102. Minimum how many states are required to construct the DFA for L(D1) ∪ L(D2)? ____

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

BASIC THEORY OF COMPUTATION Page 25


Q111. [MSQ]
Which of the following Grammars accept the language L(D1) . L(D2)?
(A) S  AB,AX1Z, X 0X | λ, BY0Z, Y 1Y | λ, Z  0Z | 1Z | λ
(B) S  0S | 1S | 0 | 1
(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

Q114. Consider the following NFA M: :

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

BASIC THEORY OF COMPUTATION Page 26


Q115. [MSQ]
Consider the following NFA with  (epsilon): :

Which of the following statement is/are true?


(A) ∈ −closure {q0 } = {𝑞0 , 𝑞1 , 𝑞2 }
(B) ∈ −closure {q1 } = {𝑞1 , 𝑞2 }
(C) ∈ −closure {q2 } = {𝑞0 , 𝑞2 }
(D) ∈ −closure {q3 } = {𝑞3 }

Q116. [MSQ]
Consider the following NFA with  (epsilon):

Which of the following statement is/are true?


(A) ∈ −closure {A} = {𝐴, 𝐵, 𝐶 }
(B) ∈ −closure {B} = {𝐵, 𝐶 }
(C) ∈ −closure {C} = {𝐶 }
(D) ∈ −closure {A} = {𝐴, 𝐵}

BASIC THEORY OF COMPUTATION Page 27


Q117. 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
∈ −𝑐𝑙𝑜𝑠𝑢𝑟𝑒 (𝑞 ) = {𝑞}
∈ −𝑐𝑙𝑜𝑠𝑢𝑟𝑒 (𝑟) = {𝑟}

Q118. Consider the following NFA with  (epsilon):

The regular expression of the following non-deterministic finite automaton is

(A)ac + b(ab)*
(B) (ac + b)(aac + ab)*
(C)(aca +ba)(b + ac)*
(D) Both b and c

BASIC THEORY OF COMPUTATION Page 28


Q119. [MSQ]
Consider the following FSA: (Where state ‘3’ is final state) :

Which of the following statements is/are true?


(a) The FSA accepts 011111101.
(b) The FSA accepts 11101000.
(c) The FSA rejects 0000.
(d) The FSA accepts all bit strings with an odd number of 0.

Q120. What is the language accepted by the following DFA?

(A) 0*1* (B) 1*0*


(C) (1+0)* 1*(0+1)* (D) (1+0)1*0(0+1)*
Q121. The regular expression for following automata will be:

(A) (011)*10(00 +1)* (B) 0*11*10(00 +1)*


(C) (0+11)*10(00)*1* (D)(0+11)*10(00 +1)*

BASIC THEORY OF COMPUTATION Page 29


Q122. What is the regular expression corresponding to the language accepted by the
following finite state automata?

(A) ((a+b)(a* (bb)*)*b(+a))*


(B) (a(a*(bb)*)*b+b(a*(bb)*)*a)
(C) (a+b)(a*(bb)*)*a
(D)None
Q123. How many of the following regular expressions that denotes a subset of the language

recognized by the given DFA? ___________

(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?

(i) a(bb + bba)*ba


(ii) ab(bb + bab)*a
(iii) ab(b+ba)*a
(A) i only (B)ii and iii only
(C)All of these (D)i and iii only

BASIC THEORY OF COMPUTATION Page 30


Q125. [MSQ]
What will be the regular expression for following automata?

(A) a*(a+b)b
(B) a*(a+b)ba*
(C) a*{((a+b)b)*a* + λ}
(D) (a +(a+b)b)*

Q126. What is the language accepted by following automata?

(A) Any string starts or ends with b


(B) The strings with an even number of characters
(C) The strings with an even number of characters and length of at least 2
(D) The strings with an even number of a’s or b’s and length of at least 2

Q127. The language accepted by the following DFA is:

(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.

BASIC THEORY OF COMPUTATION Page 31


Q128. The language accepted by the following DFA is:

(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}

Q129. The language accepted by the following DFA is:

(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}

Q130. Consider the following DFA D:

BASIC THEORY OF COMPUTATION Page 32


If L(D) is language accepted by DFA D, then which of the following language is
exactly equivalent to L(D)?
(A) All the strings containing substring 100101
(B) All the strings start with 10 and end with 01
(C) All the strings start with 100 and end with 101
(D) All the strings of length greater than or equal to six.

Q131. The following DFA accepts

(A) All the strings that contains 101 as substring


(B) All the strings that ends with 101
(C) All the strings does not end with 0
(D) All the strings that ends with 01

Q132. The following DFA accepts

(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

BASIC THEORY OF COMPUTATION Page 33


Q133. The following DFA accepts

(A) All the strings containing 111 as the substring.


(B) All the strings containing 111and 000 as the substring.
(C) All the strings start with 111 and ends with 000.
(D) All the strings containing 111 a substring and ends with 000.
Q134. Which of the following finite automata accepts different language than other three?

Q135. Consider the following two DFAs

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

BASIC THEORY OF COMPUTATION Page 34


Q136. Minimum number of states in a deterministic finite state automaton (FSA) that
recognizes all bit strings with a multiple of three 1's. (For example, the following
strings are in the language: 111, 111111, 1110, 0111, 10011, but not 1, 11, 1111, 0110.
______

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}__________

Q138. Consider the following language:

L = {w ∈ {a, b}∗| every a’s in w is followed immediately by the string bb}.


Minimum number of states in a deterministic finite state automaton for L is
__________
Q139. Minimum number of states in a DFA for the language L = {abnam | n>3, m>2 } is___

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 (*)*_________

BASIC THEORY OF COMPUTATION Page 35


Q142. Consider the following DFA D over the alphabet  = {a, b, c}:

The number of state states in minimized DFA will be _______


Q143. Consider the following DFA over {a, b}

How many states does the minimized DFA have? _________


Q144. Consider the finite automaton MDL = ({S, S1, S2, S3, D1, D2}, {a, b, c} , S,{D1,D2},

where  is defined as follows:


(S, a)  S1 (S, b)S2 (S, c)  S3 (S1, a)  D1
(S1, b) S2 (S1, c)  S3 (S2, a)  S1 (S2, b)  D2
(S2, c)  S3 (S3, a)  S1 (S3, b)  S2 (S3, c)  D2
(D1, a) D1 (D1, b)  D1 (D1, c)  D1  (D2, a)  D2
(D2, b)  D2 (D2, c) D2
Minimum number of states in DFA of given MDL is___________
Q145. Consider the following NFA

The number of states in the equivalent minimized DFA will be? ____________

BASIC THEORY OF COMPUTATION Page 36


Q146. Consider the following NFA

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}:

The numbers of states in the equivalent minimized DFA is__________

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)*} ?__________

BASIC THEORY OF COMPUTATION Page 37


Q150. What is the minimum number of states of an equivalent DFA corresponding to

Following NFA? (Assume  = {a, b, c})

(A) 2 (B) 3 (C) 4 (D) 5


Q151. Minimum numbers of states required to construct the equivalent DFA of the following
NDFA? __________

Q152.
S Suppose we apply minimization to the following DFA over {a, b}:

Which of the following correctly describes the resulting DFA M?


(A) M has 3 states, 1 of which is accepting.
(B) M has 3 states, 2 of which area accepting.
(C) M has 2 states, 1 of which is accepting.
(D) M has 4 states, 2 of which are accepting
Q153. Suppose that there are two DFA's D1 and D2. DFA D1 has 7 states out of which 3
states are final states. DFA D2 has 6 states out of which 4 states are final states. In the
product DFA for the intersection of their languages, maximum how many final states
Will be there?
(A) 12 (B) 9
(C) 3 (D) 1

BASIC THEORY OF COMPUTATION Page 38


Q154. Suppose that there are two DFA's D1 and D2. DFA D1 has 7 states out of which 3
states are final states. DFA D2 has 6 states out of which 4 states are final, In the product
DFA for the union of their languages, how many final states will be there?
(a) 42 (b) 34
(c) 2. (d) 18

Q155. Suppose we have a DFA D = (Q, Σ, δ, q0, F) and know that D accepts every string.

What can we infer about D?


(A) Every state in D is a final state.
(B) There is at least 1 state in D that is not final.
(C) Every reachable state from q0 in D is a final state.
(D) There is only 1 character in the alphabet.

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

Q157. Which of the following languages is/are regular?

(A) L1 = {wz: |w| = |z|, w  (a + b)* and z  (b + c)*}.


(B) L2 = {w: every a in w is followed by at least one b and at least one c}.
(C) L3 = {w: w does not have the same number of a’s, b’s, and c’s}.
(D) L4 = {w: w contains the same number of patterns ac and abc}.

Q158. Which of the following is/are regular?

(i)L1 = {akbmcn | (k = m or m = n) and k + m + n  2}


(ii) L2 = {akbmcn | (k = m or m = n) and k + m + n ≤ 2}
(iii) L3 = {akbmcn | k + m + n  2}
(A) i, ii, iii only (B) ii, iii only
(C) ii only (D) iii only

BASIC THEORY OF COMPUTATION Page 39


Q159. Which of the following languages over Σ = {a, b} is/are not regular?

(i) {ambn|m, n  N};


(ii) { ambn |m  n};
(iii) { ambn| m + n  4};
(iv) {w*|wL}; where L is some given language which is regular.
(v) {w*|wL}; where L is some given language which is not regular.
(A) i and iii only (B) i, iii and iv only
(C) ii and v only (D) ii, iv and v only

Q160. For which of the following languages over the alphabet {a, b} is /are not regular?

(i) L1 = {w | w is not a palindrome}


(ii) L2 = {ak | k is multiple of 4}
(iii) L3 = {ak | k mod 6 = 1 or 5}
(iv) L4 = {wxw | ‘x’ can be any non-empty string and |w|<=3}
(A) i and iv only (B) ii and iii only
(C) iii and iv only (D) i only

Q161. For which of the following languages over the alphabet {a, b} is/are regular?

(i) L1 = { ww | w∈ {𝑎}∗ }


(ii) L2 = { ww | w∈ {𝑎, 𝑏}∗}
(iii) L3 = { w1w2 | w1∈ {𝑎}∗ 𝑎𝑛𝑑w2∈ {𝑏 }∗ }
(iv) L4 = {w | w∈ {𝑎, 𝑏}∗ and w contains the same number of a's and b's}
(v) L5 = {w | w∈ {𝑎, 𝑏}∗ and w contains the same number of a's and b's and that
number is no more than 128}
(A) i, iii and v only (B) iii and v only
(C) ii and iv only (D) i, ii and iii only
Q162. Which of the following languages is/are regular?

(A) L1 = {wz: |w| = |z|, w  (a + b)* and z  (b + c)*}.


(B) L2 = {w: every a in w is followed by at least one b and at least one c}.
(C) L3 = {w: w does not have the same number of a’s, b’s, and c’s}.
(D) L4 = {w: w contains the same number of patterns ac and abc}.

BASIC THEORY OF COMPUTATION Page 40


Q163. Which of the following language is/ are not regular?
(i) L1 = {ak!: k≥1}
(ii) L2= (ak : k is perfect square}
(iii) L3 ={wϵ{a, b}*: |w| = 4 *na(w)}
(A) L1 and L2 only (B) L2 and L3 only
(C) L1 and L3only (D) All the above

Q164. Which of the following language is/ are regular?

i) L1 = {w{0, 1}* | (n0(w) − n1(w)) mod 3) = 0 }.


ii) L2 = {w {0, 1}*| (|n0(w) − n1(w)| mod 3) = 1 }.
(A) I only (B) ii only
(C) Both L1 and L2 (D) Neither L1 nor L2

Q165. Which of the following languages is/are regular?

i) L1 = { anbl : n ≥ 100, l ≤ 100 }.


ii) L2 = {uwwRv : u, v, w ∈ {a, b}+}
iii) L3 = {uuRv : u, v ∈ {a, b}+ }
(A) i and ii only (B)i and iii only
(C)i, ii &iii (D)None of three

Q166. Which of the following languages is/are regular?


L1 = {uwwRv: u, v, w ϵ{a,b}+}
L2 = {uwwRv: u,v, wϵ{a,b}+,|u|≥|v|}
L3 = {wwRv: v,wϵ{a,b}+}
(A) L1 only (B) L2 and L3 only
(C) L1 and L2only (D) L1 and L3 only
Q167. Which of the following language are not regular?
L1 = {anblak: k≥n+l}
L2 = {anbl: n+l≥0}
L3 = {anbk: n≥100 and k≤100}
(A) L1 only (B) L2 and L3 only
(C) L1 and L2 only (D) L1 and L3 only

BASIC THEORY OF COMPUTATION Page 41


Q168. Which of the following languages is/are regular?

L1={akbk: k≥1}{akbl: k≥1, l≥1}


L2 = {ak+1bk+1: k≥0} (ak+1bk+3:k≥ 0}
L3 = {ww: wϵ {a}+}
(a) (A) All the above
(B) L2 and L3 only
(C) L1 and L2 only
(D) L1 and L3 only

Q169. Which of the following language is/ are regular?

1. L = {anbman : m, n  0}
2. L = {anananbmbmbm : m, n  0}
3. L = {anbm : mn and m≤10, n  0}
(A) 2 only
(B) 2 & 3 only
(C) 1 only
(D) none of these

Q170. Which of the following language is/ are not regular?

1. L = {xy : x L1 and yL1; where L1 is regular}


2. L = {w1w2 :w1, w2  L2; where L2 is regular}
3
3. L = {𝑎𝑖 : 𝑖 ≥ 0 𝑎𝑛𝑑 𝛴 = {𝑎}}
(A)1& 3 only
(B) 2 only
(C) 3 only
(D)All

Q171. [MSQ]

Which of the following languages is/are regular?


(A) L1 : { wxwR |w, x ∈ {a, b}*} , wR is the reverse of string w
(B) L2 : { an b2m | m≤1000 or n1000 }
(C) L3 : { ap bq cr |p<10 and q>100 and r ≥ 0 }
(D) L4 : {anbnw | n >= 0 and w ∈ {a, b}*}

BASIC THEORY OF COMPUTATION Page 42


Q172. [MSQ]
Which of the following languages is/are not regular?
(A) L1 = {wRxw : w, x Σ*}
(B) L2 = {wwRx : w, x Σ+}
(C) L3 = {wxwR : w, x Σ+}
(D) L4 = {wxw : w, x Σ+}

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

statement is/ are true?


I. {(L1)+ U *} is regular.
II. (L2)* is also regular.
III. (L1.(L2  λ))* is also regular.
(A)I & II only
(B)II& III only
(C)I & III only
(D) All the above

Q175. [MSQ]
Let L1 and L2 are two regular languages over  then which of the following is/are
regular?
(A) L = {xΣ* | either xL1 or xL2}
(B) L = {xΣ* | xL1 but xL2}
(C) L = {xΣ* |xyL1 or xyL2; where yΣ*}
(D) L = {xΣ* | xyL1 and |x| = |y|}

BASIC THEORY OF COMPUTATION Page 43


Q176. Which of the following language is regular?
(A) L = {ak : k is not perfect square}
(B) L = {ak : k is perfect cube}
(C) L = {ak : k is either prime or product of two or more prime numbers}
(D) L = {ak : k = 2i for some i  0}

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 : n1}U {anbm : n, m 1}
(C) L = {w1w2: w1 = w2 and w1, w2 Σ*}{anbn : n1}
(D) L = {an: n = k3 for some k0}

Q179. Which of the following is/are true?


(a) Union of two non-regular languages is always non-regular.
(b) Union of a regular language with a disjoint non-regular language is always
non-regular.
(c) L ((ab*ba*) ∩ (ba*ab*)) = {ε}.
(d) L = {1n : n ≤ 1000 and n is prime}. A DFA accepting L may have less than 900 states.

Q180. Which of the following languages are not regular?

1. L = {wwwwR : w{a, b}*}


2. L = {w{a, b}*| w = wR}
3. L = { w{a, b}*| w has more a’s than b’s} 4. L = {a2nb4nan}
(A)1 & 2 only (B) 2, 3 & 4 only
(C)1, 3& 4 only (D)All the above

BASIC THEORY OF COMPUTATION Page 44


Q181. Given that L is regular and

L1 = {wx: wΣ* and xL},

L2 = {w: wxL and |w| = |x|}, and

L3 = {w: wxL1, for some xL2}

Which of the above language is/are regular?

(A) L1, L2 only

(B) L2, L3 only

(C) L1, L3 only

(D) All are regular

Q182. Which of the following statement/s is are true?


I. If A is a non-regular language and B is a language such that B ⊆ A, then B must be
Non-regular.
II. If (L1.L2 U L3) is regular, L3 is regular and complement of L2 is regular then L1
must be regular.
(A) I only
(B)II only
(C)Both
(D)Neither I nor II

Q183. Select the correct statement


1. A DFA with n states must accept at least one string of length greater than n.
2. A DFA with n states that accepts an infinite language must accept at least one
string x such that 2n < |x| ≤ 3n.
3. If R is a regular language and L is some language, and L ∪ R is a regular language,
then L must be a regular language.
4. If F is a finite language and L is some language, and L − F is a regular language,
then L must be a regular language.
(A) 2 only (B) 1 and 3 only
(C) 2 and 4 only (D) None

BASIC THEORY OF COMPUTATION Page 45


Q184. Which of following is/are correct?
S1: Let r1 and r2 be two regular expressions. Then L ((r1 + r2)*) = L ((r1*r2*)*).
S2: Let L4 = L1 · L2 · L3. If L1 and L2 are regular and L3 is not regular, it is possible
that L4 is regular.
(A) Only S1
(B) Only S2
(C) Both S1&S2
(D) )either S1 nor S2

Q185. Which of following is/are correct?

S1: L1 ⊆ L ⊆ L2 where L1 and L2 are regular, then L must be regular.


S2: {w = xyzy | x, y, z ∈ {0, 1}+} is regular.
(A) Only S1
(B) Only S2
(C) Both S1&S2
(D )either S1 nor S2

Q186. Which of following statement is/are correct?


S1: (∅* · ∅)* · ∅* = ∅
S2: {xyxR | x, y ∈ {a, b}+} is regular.
(A) Only S1
(B) Only S2
(C) Both S1&S2
(D) either S1 nor S2

Q187. Which of following statement is/are correct?


S1: If L1.L2 is regular then at least one of them (L1 or L2) is regular.
S2: If L1.L2 is non-regular then at least one of them (L1 or L2) is non-regular.
(A) Only S1
(B) Only S2
(C)Both S1&S2
(D)None of them

BASIC THEORY OF COMPUTATION Page 46


Q188. Select the correct statement:

(A) If L1 is regular and L2 L1, then L2 is regular as well.


(B) If L1 is regular and L2 is not regular, then L1 U L2 is not regular.
(C) If L1 is regular and L1 U L2 is not regular, then L2 is not regular.
(D) If L1 is regular and L2 is not regular, then L1 L2 is not regular.
Q189. Select the correct statements

(1) L1 = L2 if and only if L1* = L2*


(2) For any languages L1, L2 and L3, L1 (L2  L3)  (L1L2)  (L1L3)
(3) For any languages L1, L2 and L3, (L1L2)  (L1L3)  L1 (L2  L3).
(A) 1 and 3
(B) 2 and 3
(C) 2 only
(D) None.

Q190. Consider the following statements:


1. An infinite language can have an infinite complement.
2. All infinite languages have infinite complements.
3. The union of infinitely many regular languages is always regular.
Which of the above statements is/are true?
(A) 1 only
(B) 1 and 2 only
(C) 1 and 3 only
(D) 2 and 3 only

Q191. Consider the following statements

1. If L is regular then so is {xx : x  L}.


2. If L is regular then so is {xy : x, y  L}.
𝑝
3. Let A = {12 : p is prime}. Then A* is regular.
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

BASIC THEORY OF COMPUTATION Page 47


Q192. Select correct statements:

S1: If L1 and L2 are non-regular languages then L1  L2 is also non-regular.


S2: IfL1 is non-regular language and L2 is regular language then L1.L2 may be
regular language.
S3: If L1L2 and L2 are regular then L1 may not be regular.
(A) S1 and S2 only
(B) S2 and S3 only
(C) S1 and S3 only
(D) All the above.

Q193. Select correct statements:


S1: For every regular language L, every subset of L is regular as well.
S2: Every non-regular language is infinite.
S3: The intersection of any two non-regular languages is non-regular.
S4: If each of the languages L1, L2 . . . is regular, then ⋃∞
𝑖=1 𝐿𝑖 is regular as well.

(A) S1 and S2 only


(B) S2 and S3
(C) S3 and S4
(D) S2 and S4

Q194. Let L1 and L2 are two languages over  and it is given that L1.L2 is non-regular

languages. Then which of the following statement is not always true?


(A) ̅̅̅̅
𝐿1 is not regular.
(B) L1 ∪̅̅̅̅
𝐿1 is regular.
(C) L1, L2 ⊆ Σ*
(D) L1∪L2 contain infinitely many strings.

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)*

BASIC THEORY OF COMPUTATION Page 48


Q196. The set of non-regular languages is closed under which of the following operations?
(A) Complement
(B) Union
(C) Intersection
(D) Concatenation
̅̅̅̅̅̅̅̅̅
Q197. Let L1 = {anbncm | n, m>=0} and L2 = {anbmcm | n, m>=0} then what is𝐿1
̅̅̅𝐿2̅̅̅ ?
̅̅̅
(A) L1U 𝐿2
(B)* - {anbncn | n>=0}
(C) {anbncn | n>=0}
(D) a*b*c*
Q198. The right quotient of a language L1 with respect to L2 is defined as L1/L2 = {x: yL2,

xyL1} 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

{abb, ba, bba}?


( (A) abbbabbaabb
(B) abbbba
(C)abbbbababb
(D) abbbabbababbaba
Q200. Let L1 = {a, ab, c, d, λ}, L2 = {d} and L3 = L1.L2. Which string is not in L3?

(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

BASIC THEORY OF COMPUTATION Page 49


Q202. If L = {001, 1101, 101} then the suffix of L is
(A) {𝜆, 0, 00, 001, 1, 11, 110, 1101, 1, 10, 101}
(B) {λ, 1, 01, 001, 101, 1101, 10, 110}
(C) {λ, 1, 01, 001, 101, 1101}
(D) None of the above

Q203. Consider the following NFA:

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

Q204. Consider the following NFA

Which Regular grammar corresponds to the following NFA?


(A) S  bA | aS, A aB | , BbA
(B) S  bA | aS, A bB | , BbA
(C)S  Ba, A  aB | , B  bA
(D)None

BASIC THEORY OF COMPUTATION Page 50


Q205. Consider the following NFA.

Which of the following is a left linear grammar for the language accepted by M?
(A) S 1S0|
(B) S 10S|
(C) S 1A|, A0S
(D)S A0| , AS1

Q206. How many of the following statement(s) is/are true? ________


(i)The language generated by the grammar G = ({S}, {a}, S, {S → Saaa | aS | a }) is not
regular.
(ii) The language generated by the grammar G = ({S}, {a}, S, {S → aSSa | aS | a }) is
regular.
(iii) The language generated by the grammar
G = ({S}, {a}, S, {S → bSb | aSa | a | b })is regular.
(iv) The language generated by the grammar G = ({S}, {a}, S, {S → bSa | λ | a }) is not
regular.
Q207. Consider a generated grammar G with production

S abA
AbaB
BaA | 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

BASIC THEORY OF COMPUTATION Page 51


Data for next two question: Consider a language L = {anbm : n2, m3}
Q208. Which of the following grammar is left-linear grammar for given L?

(A) SS1S2, S1aaA, AaA|λ, S2bbbB, BbB|λ


(B) SS1bbb, S1S1b | A, AaaB, BaB|λ
(C) SaaA, AaA|B, BbbbC, CbC|λ
(D) none of these

Q209. Which of the following grammar is right-linear grammar for given L?

(A) SS1S2, S1aaA, AaA|λ, S2bbbB, BbB|λ


(B) SS1bbb, S1S1b | A, AaaB, BaB|λ
(C) SaaA, AaA|B, BbbbC, CbC|λ
(D) None of these

Q210. Consider following grammar G

SaA|bB|λ,
AbC|aS,
BaC|Bs
CaB|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}

Q211. Consider following grammar G

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)+

BASIC THEORY OF COMPUTATION Page 52


Q212. The language generated by the grammar with productions where  = {a, b} is?

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

Q213. Consider the following grammar G:


S → XY
X → aX | bX | a
Y→Ya|Yb|b
The regular expression for the language generated by G is
(A) (a + b)+
(B) (a + b)*ab(a + b)*
(C) (a + b)+ab(a+ b)+
(D) (a + b)+ (a + b)+

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.

Q214. Then holomorphic image of L = {010, 102, 1011, 0100} is


(A) h(L) = {aabaabcaab, aabcaabccccd, aabcaabaabaab, aabaabcaabaab}
(B) h(L) = {aabaabcaab, aabcaabcccd, aabcaabaabaabc, aabaabcaabaab}
(C) h(L) = {aabaabcaab, aabcaabcccd, aabcaabaabaab, aabaabcaabaabc}

(D) h(L) = {aabaabcaab, aabcaabcccd, aabcaabaabcaabc, aabaabcaabaab}

Q215. Let h(L) = {aabaabaabccccdaab, cccdaabccccdaabaabc} then L will be


(A){00020, 21201}
(B){00120, 20201}
(C){00120, 21201}
(D) {00020, 20201}

BASIC THEORY OF COMPUTATION Page 53


Q216. Let A = {xx | x  {a, b}*}. Consider homomorphism h : {a, b}* → {0, 1}* with h(a) = 00,

h(b) = ϵ. What is h(A)?


(A) {04n | n ≥ 0}
(B) {0n | n ≥ 0}
(C) {02n | n ≥ 0}
(D) none of these
For next three questions suppose h is the homomorphism from {0,1,2} to {a,b} defined by
h(0) = a; h(1) = ab; h(2) = ba.
Q217. What is h(21120)
(A) baababbaa
(B) bababbaa
(C) bbaababbaa
(D) abaababbaa

Q218. If L = 01*2, then what is h(L)?


(A)aab(ab)*ba
(B) (ab)*ba
(C) a(ab)*ba
(D) aa(ab)*ab
Q219. If L = a(ba)*, then what is h-1(L)?

(A) 02*1*0
(B) 02*
(C) 1*0
(D) 02*U 1*0

Q220. The pumping lemma for regular languages implies that

(A) Every regular language contains a string that can be pumped.


(B) All strings in a regular language can be written as uvw so that uv iw is also in
the language when i ≥ 0.
(C) A regular language is infinite if and only if it contains a string that can be
pumped
(D) Regular languages are closed under the regular operations

BASIC THEORY OF COMPUTATION Page 54


Q221. Let L = {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) regular because it is described by a regular expression
(D) not regular because apbp cannot be pumped.

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

Q223. The pumping lemma for regular languages can be proved by


(A) showing that an NFA can be converted to an equivalent DFA.
(B) showing that the regular languages are closed under the regular operations.
(C) showing that an NFA computation must repeat a state.
(D) showing that a DFA computation must repeat a state.
Q224. Consider the language L= {w : Σ* w is a palindrome } is not regular.

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

BASIC THEORY OF COMPUTATION Page 55


Q226. Let L be the regular language (11)*0*1* and L' = {(11)n10m1m | n, m>= 0}. Then L  L'

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.

BASIC THEORY OF COMPUTATION Page 56


CONTEXT FREE LANGUAGE
Q1. Which of the following languages is/are context free languages?
(I) L = {anbj | n ≤ j2}
(II) L = {anbjck | k = j*n}
(III) L = {anbjck | n < j, n ≤ k ≤ j}
(A)I & II only (B) II & III only
(C) I & III only (D) None of the above

Q2. Which of the following language is/are NCFL?


(I) L = {ambncpdq | n = q or m ≤ p and m+ n = p + q}
(II) L = {ambncp | m = n or n = p or m = p}
(III) L = {ambncp | m = n and n = p and m = p}
(IV) L = {ambncp | m  n or n  p or m  p}
(A) II & IV only (B) I & IV only
(C) I & II only (D) None of above

Q3. Which of the following language is/are context free?


L1 = {anbj| n ≤ j2}
L2 = {an| n is prime}
L3 = {anwwRan | n ≥ 0 and w{a, b}*}
L4 = {anbjajbn| n ≤ j}
L5 = {xy| x, y {0, 1}* and x ≠ y}
(A) L3 and L4 only (B) L1 and L4 only
(C) L2 and L5 only (D) L3 and L5 only

Q4. Which of the following language is/are context free?


L1 = {anbnanbn : n ≥ 0}, Σ = {a, b}.
L2 = {wR#z : w is a substring of z, w, z ∈ {a, b} ∗}, Σ = {a, b, #}.
L3 = {w#z : w is a substring of z, w, z ∈ {a, b} ∗}, Σ = {a, b, #}.
L4 = {x+y=z : x + y = z in unary where x, y, z ∈ 11∗}, Σ = {1, +, =}.
(A) L3 and L4 only (B) L2 and L4 only
(C) L4 only (D) None

BASIC THEORY OF COMPUTATION Page 57


Q5. Which of the following language is/are NCFL but not DCFL?
L1 = {wywR : the length of y is even}, Σ = {a, b}.
L2 = {w : w has the same number of a’s b’s and c’s together}, Σ = {a, b, c}.
L3 = {aibjck : i> j or j > k, where i, j, k ≥ 0}, Σ = {a, b, c}.
L4 = {xy : |x| = |y| and x ≠ y}, Σ = {a, b}.
(A) L3 only (B) L1 and L2 only
(C) L2 and L4 only (D) L1, L3 and L4 only

Q6. Which of the following language is/are DCFL?


L1 = {wwR| w  a*b*}
L2 = {w| w {a, b}* and each prefix of w has at least as many a’s as b’s}
L3 = {w| w  {a, b}* and m  na(w) = k  nb(w) for arbitrary constants m and k}
(A) Only L2 (B) L2 and L3
(C) L1 and L3 (D) All of the above

Q7. Which of the following language is/are NCFL?


(i){0n1n| n >0}∪ {0n12n| n ≥ 0}
(ii){1n0n1m| m, n >0}∪ {1m0n12n| m, n ≥ 0}
(iii){0n1n| n >0}∪ {12n0n| n ≥ 0}
(A) i only (B) i and ii only
(C) iii only (D) ii only

Q8. Which of the following language is/are context free?


(i) L = {anbn: n  0 and n is not a multiple of 5}
(ii){1k0i1i0j1j0k | i, j, k > 0}
(iii) {w#x | w is a substring of x, where w, x are in {0,1}*}.
(iv) {0i1i0j1i | i, j > 0}
(v) {(0n1n)m| m, n > 0}.
(vi) Complement of {(0n1n)m| m, n > 0}.
(A) i, ii and vi only (B) i and ii only
(C) iii and v only (D) i, ii, iii and v only

BASIC THEORY OF COMPUTATION Page 58


Q9. Which of the following language is/are context free?
L1 = {w {a, b, c}* |na(w) = nb(w) ≤nc(w)}
L2 = {anbm| n and m are both prime}
L3 = {anbjakbl| n ≤k, j ≤l}
L4 = {w {a, b}*|na(w) = nb(w),w does not contain a substring aab}
(A)L2 only (B)L1 and L3 only
(C)L4 only (D)None

Q10. The language L = {(a+b+c)*wcwR, where w (a+b)+} is


(A) Regular (B) Deterministic CFL
(C) Non- Deterministic CFL (D) Not a CFL

Q11. The language L = {wRcw (a + b + c)*, where w (a+b)+} is


(A) Regular (B) Deterministic CFL
(C) Non- Deterministic CFL (D) Not a CFL

Q12. Which of the following is/are not CFL?


(i) L = {www | w {0, 1}}
(ii) L = {0n | n is perfect square}
(iii) L = {0n | n is either prime number or odd number or both}
(iv) L = {0n | n is not perfect cube}
(A) i only (B) ii and iv only
(C) ii, iii and iv only (D) i and iv only

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}.

BASIC THEORY OF COMPUTATION Page 59


Q14. [MSQ]
Which of the following language is/are context free?
(A) L1 = {w {a, b, c} | na(w) = nb(w) = nc(w)}
(B) L2 = {anbm |n/m is integer ;where n & m are prime numbers}
(C) L3 = {anbjakbl | n = k and j =2l}
(D) L4 = {ww | w {a, b}*and na(w) < 2nb(w)) <100}

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}*}

Q17. Which of the following language is/are DCFL?


1. L = {www | w 0*}
2. L = {wxw |w0*1* and x{0, 1}* }
3. L = {wxwR |w0*1* and x{0, 1}* }
(A) 1 only
(B) 1 & 2 only
(C) 2 & 3 only
(D) All the above

BASIC THEORY OF COMPUTATION Page 60


Q18. Which of the following descriptions best fits the language
L = {x  {a b, c }* | #a(x) = #b(x) + #c(x) }
(A) L is a regular language
(B) L is a context-free language that is not regular
(C) L is a context-sensitive language that is not context-free
(D) L is not a context-sensitive language

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

BASIC THEORY OF COMPUTATION Page 61


Q22. Which of the following languages is/are context free?
1. {ai| i is prime}
2. {(anb)n|n 1}

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

Q25. Which of the following languages is/are CFLs?


L1 = {0i1j2k |i<j<k}.
L2 = {w(0+1+2)*| w does not contain the same number of all 3 symbols}.
L3 = {uawb|u,w(a+b)*,|u|=|w|}
L4 = {bibi+1|bi is i in binary i  1}. The alphabet here is {0,1,}.
(A)L1 and L2 only
(B) L2, L3 and L4 only
(C) L3 only
(D) L3 and L4 only

BASIC THEORY OF COMPUTATION Page 62


Q26. Which of the following languages is/are context free?
L1 = {aibkcj | j = max (i, k) }
L2 = {x ∈ {a, b}* : |x| is even and the first half of x has one more ‘a’ than does the
second half}.
L3 = {w ∈ {a, b}* : the first, middle, and last characters of w are identical}.
L4 = {aibj |i = kj for some positive integer k}
(A) L2 only (B) L3 only
(C) L1 & L2 (D) L2 & L3

Q27. Consider the following language L = {wR#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.

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.

Q29. The language L = {0i1j2i3j |i, j ≥ 0} is


(A) Regular
(B) Deterministic CFL
(B) Non-Deterministic CFL
(D) Not a CFL

Q30. The language L = {0i1j2j3i |i, j ≥ 0} is


(A) Regular (B) Deterministic CFL
(C) Non-Deterministic CFL (D) Not a CFL

BASIC THEORY OF COMPUTATION Page 63


Q31. The language L = {0i1j |i, j ≥ 0 and i = 3j} is
(A) Regular (B) Deterministic CFL
(C) Non-Deterministic CFL (D) Not a CFL

Q32. Which of the following language/s is/are not CFL?


1. L = {anbncmambncn | n  0, m  0}
2. L = {anbmcn| n = 3m & n  0, m  0}
3. L = {ambncm#wwR#wcwR| w{a, b}* and wR is reverse string of w}
(A)1 only (B)2 & 3 only
(C)1&2 only (D)none

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.

Q34. Which of the following languages on 𝛴 = {a, b} is/are context- free?


(i) L = {aibj | i ≤ j3}
(ii) L = {aibj | i + j is an even number}
(iii) L = {aibj | i * j is composite number}
(iv) L = {aibj | i + j is an odd number}
(A) Only i, iii (B) ii, iv only
(C) Only i, ii and iv (D) all

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

BASIC THEORY OF COMPUTATION Page 64


Q36. Which of the following language is/are DCFL?
(A) L = {anbm| n m }
(B) L = {w#wR|wR is reverse of w}
(C) L = {anbm | n≤m≤3n}
(D) both a & b
Q37. Which of the following language is/are not CFL?
1. L = {anbmck | k = HCF(m, n)}
2. L = {anbmck | k = LCM(m, n)}
3. L = {anbmck | k = max(m, n)}
4. L = {anbmck | k = min(m, n)}
(A)1 & 2 only
(B) 3 & 4 only
(C)2 & 4 only
(D) All the above
Q38. Which of the following language/s is/are CFL?
1. If L1 = {wwR| wR is reverse of w} then L1.L1.L1 is CFL.
2. If L2 = {wwRwwRwwR| wR is reverse of w} then L2 is CFL.
3. If L3 = {wwR| wR is reverse of w}, then complement of L3 is NCFL.
(A)1 only
(B)1 & 3 only
(C)2 & 3 only
(D)All the above
Q39. Which of the following language is/are DCFL?
1. L = {uv : u vR where u, v Σ* and vR is reverse of v}.
2. L = {uv : u contains even number of 0 and v contains odd number of 1;
Where u, v  {0, 1}*}.
3. L = {uv : u L1& vL1; where L1 is DCFL }
4. 1. L = {u#v : u vR where u, v Σ* and vR is reverse of v}.
(A) 1, 3 only
(B) 1, 3, 4 only
(C) 2, 3, 4 only
(D) All the above

BASIC THEORY OF COMPUTATION Page 65


Q40. Which of the following languages are NOT context-free?
L1 = {0n+m1n0m|n, m ≥ 0},
L2 = {0n+m1n+m0 m |n, m ≥ 0}, and
L3 = {0n+m1n0n+ m |n, m ≥ 0}
(A) L1only
(B) L3 only
(C) L1 and L2
(D) L2 and L3

Q41. A context-free grammar G is ambiguous if and only if


(A) Some string w ∈ L(G) has at least two different derivations.
(B) Some string w ∈ L(G) has at least two different parse trees.
(C) Every string w ∈ L(G) has at least two different parse trees.
(D) Every string w ∈ L(G) has at least two different derivations.

Q42. Consider the following grammar: (Assume starting symbol is S)


G1 G2
S  aA | bB | cS | aS S  aS | bSa | aSb | bS
A  bAa | λ |λ
B  bB | a
Which of the following grammar is/are ambiguous?
(a) G1 only (b) G2 only
(c) Both G1 & G2 (d) Neither G1 nor G2

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|λ S0|1 S  0S1S
Y1Y1 | 0Y0 | Y1Y| 0Y |λ S λ
λ

BASIC THEORY OF COMPUTATION Page 66


Q44. [MSQ]
Consider the following grammar G with starting symbol S:
S  aSb | bSa | aSa | bSb | AB | BA
A  aA | λ
B  bB | λ
For which of the following string(s), G has more than one parse tree?
(A) ab
(B) aabb
(C) abba
(D) abab

Q45. Consider the following grammar G with starting symbol S:


S  aSb | bSa | aSa | bSb | AB | BA
A  aA | λ
B  bB | λ
How many different parse trees are possible for string ‘abba’? ___________

Q46. Which of the parse trees below yield the same word?

(A) iii and iv only


(B) i, ii and v only
(C) ii and v only
(D) iii, iv and vi only

BASIC THEORY OF COMPUTATION Page 67


Q47. Here is a parse tree that is derived from some unknown grammar G.

Which of the following productions is not surely for grammar G?


(A) S → ABS
(B) A → aB
(C) S → AB
(D) S → aA

Q48. The parse tree below represents a rightmost derivation according to the grammar
S → ABS|AB|aA, A → aS|a, B → bA

Which of the following is a right-sentential form in this derivation?


(I) ABaA
(II) bAba
(III) aaBB
(IV) aabAba
(A) I & II only
(B) III & IV only
(C) I only
(D) All except III

BASIC THEORY OF COMPUTATION Page 68


Q49. Consider the following context free grammar: G = ({S, A, a, b}, {a, b}, R, S),
where R = {S aAS S  a ASbA A SS Aba } and parse tree for the string
“aaaabaa” is shown below:

Which of the following are left-sentential forms corresponding to this derivation?


(i) aAS
(ii) aSS
(iii) aaSS
(iv) aaS
(v) aaaaAS
(A)i, iii and v only
(B)ii and iv only
(C)ii, iii and v only
(D)All the above

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

BASIC THEORY OF COMPUTATION Page 69


Q51. Consider the following CFG
S → aB | bA
B → b | bS| aBB
A → a| aS| bAA
Now consider the following derivation of above CFG
S ⇒ aB ⇒ aaBB ⇒ aaBb ⇒ aabSb ⇒ aabbAb ⇒ aabbab
This derivation is
(A) a leftmost derivation
(B)a rightmost derivation
(C)both leftmost and rightmost derivation
(D)neither leftmost nor rightmost derivation

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

Q53. Consider the following grammar G with start symbol S:


S if id then S else S
S  if id then S
S  id
Which of following is/are true?
(i) G is Type 3 grammar.
(ii) G is Type 2 grammar
(iii) G is unambiguous grammar.
(iv) G is ambiguous grammar.
(A) i, ii and iv only (b) ii and iv only
(C) ii and iii only (D) i, ii and iii only

BASIC THEORY OF COMPUTATION Page 70


For the next two questions:
Consider the following grammar G
S → 0A | 1B | λ
A → 0AA | 1S | 1
B → 1BB | 0S | 0
Let L (G) is the language accepted by G.
Q54. Which of the following statements is/are true about G?
(i) G is Type 2.
(ii) G is ambiguous.
(iii) 0011010110  L (G) and 1111100101000  L (G).
(A) i& ii only
(B)ii & iii only
(C) i only
(D)All are true

Q55. The language generated by G is


(A) The set of all the strings that don’t contain substring 00.
(B) The set of all the strings that contains equal numbers of zero’s followed by equal
number of one’s or equal numbers of one’s followed by equal number of zero’s
i.e. L(G) ={0n1n|n>0} {0n1n| n>0}
(C) The set of all the strings which have equal number of zero’s and one’s.
(D)None of these
Q56. Consider the following statements about the context free grammar
G = {S -> SS, S ->ab, S ->ba, S -> ɛ}
Which of the following statements is/are true about G
I. G is ambiguous.
II. G produces all strings with equal number of a’s and b’s.
III. L (G) can be accepted by a deterministic PDA.
(A) I only
(B) I and III only
(C) II and III only
(D) I, II and III

BASIC THEORY OF COMPUTATION Page 71


Q57. Consider the grammar G given by the productions
S → aSa | aBa | b | λ
B → bB | b
Then which of the following is/are true about G?
(i)G is context sensitive grammar.
(ii)G accept the language L where L = {aibjak | i = k and i, j, k  0}.
(iii) G is not unambiguous.
(A) ii only (B) ii & iii only
(C) i & ii only (D) All are true

Q58. Consider the following grammar G


S  TC | AR
T aTb | 
C  Cc | 
R bRc | C
A Aa | 
The language is generated by G is : (Assume i, j, k>=0)
(A) L = {aibjck | k = j and i>=j} (B) L = {aibjck | i = j and k>=j}
(C) L = {aibjck | i = j or k>=0 } (D) L = {aibjck | i = j or k>=j}

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}

G1: G2: G3:


S aSc | T S aSc | T S  TC
T bTc |  T bTcc |  T aTb | 
C  Cc | ccc

Which of the following language, grammar pair (L, G) are equivalent?


(a)(L1, G1), (L2, G2), (L3, G3) (b)(L1, G3), (L2, G2), (L3, G1)
(c)(L1, G2), (L2, G2), (L3, G3) (d) (L1, G2), (L2, G3), (L3, G1)

BASIC THEORY OF COMPUTATION Page 72


Q60. Match the column which CFG corresponds to which language?
Language Grammar
1. {0n1n | n>0} U {0n12n | n>0} i. S  0A1 | 0B11
A  0A1 | 
B  0B11 | 
2. Binary strings with twice as many 1s as ii. S 0A0 | 1A1
0s. A  0A | 1A | 
3. {w  {0,1}*| w starts and ends with iii. S → 0A11 |
the same symbol} A → 0A11 | 

(A) 1-i, 2-iii, 3-ii


(B) 1-ii, 2-i, 3-iii
(C) 1-ii, 2-iii,3-I
(D) 1-i, 2-ii, 3-iii

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

BASIC THEORY OF COMPUTATION Page 73


Q63. Consider the following Pushdown Automaton (PDA) P1:
P1 = (Q = {q0, q1}, Σ = {a, b, c}, Γ = {0, 1, #}, δ, q0, Z0 = #, F = {q1}) where the transition
function δ is given by
δ(q0, a, #) = {(q0, 0#), (q0, 11#)}
δ(q0, a, 0) = {(q0, 00), (q0, 110)}
δ(q0, a, 1) = {(q0, 01), (q0, 111)}
δ(q0, b, 0) = {(q0, )}
δ(q0, c, 1) = {(q0, )}
δ(q0, , #) = {(q1, #)}
δ(q, w, z) = ∅ everywhere else Acceptance is by final state.
Which of the following words are accepted by the PDA P1?
(i) ab (ii) aababcc (iii) ac
(A)i only (B)i and ii only (C)i and iii only (D)iii only
Q64. Let M be the PDA

Which of the following strings are accepted by M?


(A)aaaa (B) baab (C) aaa (D) ab

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

BASIC THEORY OF COMPUTATION Page 74


Q66. Here are the transitions of a deterministic pushdown automaton. The start state is q 0,
and f is the accepting state.
State-Symbol a b ε
q0-Z0 (q1,AAZ0) (q2,BZ0) (f,ε)
q1-A (q1,AAA) (q1,ε) -
q1-Z0 - - (q0,Z0)
q2-B (q3,ε) (q2,BB) -
q2-Z0 - - (q0,Z0)
q3-B - - (q2,ε)
q3-Z0 - - (q1,AZ0)
Identify below the one input string that the PDA accepts.
(A) bbbab
(B)abbbab
(C)abbbabb
(D) bbaabab

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)

BASIC THEORY OF COMPUTATION Page 75


PDA to Language
Q68. Let M be the PDA defined by
Q = {q0, q1, q2} Σ = {a, b} Γ = {A} F = {q1, q2}
δ(q0, a, λ) = {[q0, A]}
δ(q0, λ, λ) = {[q1, λ]}
δ(q0, b, A) = {[q2, λ]}
δ(q1, λ, A) = {[q1, λ]}
δ(q2, b, A) = {[q2, λ]}
δ(q2, λ, A) = {[q2, λ]}
The language accepted by M is?
(A) The PDA M accepts the language {aibj| 0 ≤ i, j}
(B) The PDA M accepts the language {aibj| 0 ≤ i ≤ j}
(C) The PDA M accepts the language {aibj| 0 ≤ j ≤ i}
(D) The PDA M accepts the language {aibj| i = j}
Q69. The language accepted by following PDA is

(A) L1 = {anb3n | n ≥ 0} (B) L2 = {anbn | n ≥ 0}


(C) L3 = {anbn+3 | n ≥ 0} (D) L4 = {anbm | n ≥ 0, m > n + 3}
Q70. Let M be the PDA defined by
Q = {q0, q1, q2} = {a, b} = {A}F = {q1, q2}
(q0, a, ) = {[q0,A]}
(q0, , ) = {[q1, ]}
(q0, b,A) = {[q2, ]}
(q1, ,A) = {[q1, ]}
(q2, b,A) = {[q2, ]}
(q2, ,A) = {[q2, ]}
The language accepted by M is:
(A){aibj| 0≤ 𝑗 ≤ 𝑖} (B){aibj| 0≤ 𝑖 ≤ 𝑗}
(C){anbn| n≥ 0} (D){(ab)n | n≥ 0}

BASIC THEORY OF COMPUTATION Page 76


Q71. The language accepted by following PDA is:

(A){aibj| 0≤ 𝑗 ≤ 𝑖} (B){aibj| 0≤ 𝑖 ≤ 𝑗}
(C){anbn| n≥ 0} (D){(ab)n | n≥ 0}

Q72. The language accepted by following PDA

(A){aibjck | i + k = j}
(B) {aibjck | i<j=k }
(C) {aibjci | i=j }
(D) {aibjck | i<j and k>0}

Q73. The language accepted by following PDA is:

(A){aicjbi | i,j≥ 0}
(B) {aicjbk | i, j, 𝑘 ≥ 0}
(C) {aicjbi | i, j> 0}
(D) {aibi | i≥ 0}

BASIC THEORY OF COMPUTATION Page 77


Q74. The language accepted by following PDA is

(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

Which of the following grammar is equivalent to given PDA?


(A) S → SS | aSb | ab
(B) S → SS | ab | λ
(C) S → SS | aSb | λ
(D) S → aSb | λ
Q76. The language accepted by following automata is

(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}

BASIC THEORY OF COMPUTATION Page 78


Q77. The language accepted by following automata is

(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

The language accepted by following PDA is?


(A) L = {anbncm : n>=0, m>=0}
(B)L = {anbmcm : n>=0, m>=0}
(C) L = {anbm+ncm : n>=0, m>=0}
(D)L = {anbncm : n>=0, m>=0}

BASIC THEORY OF COMPUTATION Page 79


Q80. The language is accepted by the following PDA is

M = (q0, q1,...., q5},{a, b},{0,1,a,z},,z,q0,{q5}),


(q0,b,z)={(q1,1z)},
(q1,b,1)={(q1,11)},
(q2,a,1)={(q3,)},
(q3,a,1)={(q4,)}
(q4,a,z)={(q4,z),(q5,z)}
(A){biaj+3|i≥1,j≥ 0} (B){biaj+3|i≥1,j≥ 1}
(C) {} (D) ∅
Q81. The language accepted by following PDA is

(A) L = {anbmcn+m n ≥ 0,m ≥ 0}. .


(B) L = {anbn+mcm |n ≥ 0,m ≥ 0}
(C) L = {anbmcm n ≥ 0,m ≥ 0
(D) L = {anbmcn n ≥ 0,m ≥1}

Q82. The language accepted by following PDA is

(A) L = {anbmcm n ≥ 0, m ≥ 0} (B) L = {a3bmcm m ≥ 0}


(C)L = {a3nbmcm n ≥ 0, m ≥ 0} (D) None

BASIC THEORY OF COMPUTATION Page 80


For next two Question: Push down automata for
P = {Q = {q0, q0},  = {[,]},  = {A, B}, q0, F = { q1}, δ }
δ(q0,[, ε) = {( q0,A)}
δ(q0,], ε) = {( q0,B)}
δ(q0, ε, ε) = {( q1, ε)}
δ(q1,[,A) = {( q1,ε)}
δ(q1,],B) = {( q1, ε)}
δ(q, a, x) = ∅ otherwise
Q83. Suppose the current instantaneous description of P is < q1, AAAAA> and the unread
portion of the input is []][. The instantaneous description after one step is
(A) The machine crashes (B) < q1, AAAAAA>
(C) < q1, AAAA> (D) < q1, AAA>

Q84. The language recognized by PDA is


(A) {[ n ]n | n≥0} (B) {[ i ] j : i≥j≥0}
(C) {wu | w, u {[,]}* and u is prefix of wR} (D) None of these
Q85. The language accepted by following PDA is

(A) L = { na(w) + nb(w) = nc(w)} (B) L={anbmcm |m,n≥0}


(C) L = { na(w) + nc(w)= nb(w)} (D)None

Closure properties of CFL, DCFL, (DPDA, NPDA)


Q86. Let L1 be a context-free language and let L2  L1.
(A) L2 is definitely context-free.
(B) L2 may be a context free language.
(C) L1 and L2 is definitely not context-free.
(D) L2 never be a regular

BASIC THEORY OF COMPUTATION Page 81


Q87. Let L1 and L2 be two DCFL’s. Then L1  L2 is guaranteed to be:
(A) Context-Free (B)Deterministic Context-Free
(C) Regular (D)can’t say

Q88. Let L1 and L2 be two DCFL’s. Then L1 U L2 is guaranteed to be:


(A) Context-Free (B)Deterministic Context-Free
(C) Regular (D)can’t say

Q89. Let L be a DCFL. Then *- L is guaranteed to be


(A) Non-Deterministic Context-Free (B)Deterministic Context-Free
(C)Regular (D)can’t say

Q90. Which of following is/are correct?


S1: If L1 and L1 U L2 are context free, then L2 must be context free.
S2: If L1 is context free and L2 is regular, then L1 − L2 is context free.
(A)Only S1 (B)Only S2
(C)Both S1&S2 (D)None of them
Q91. Which of following is/are correct?
S1: If L1 is regular and L2 is context free, then L1 − L2 is context free.
S2: If L1 is regular and L2 is context-free, then L1  L2 must be a CFL.
(A)Only S1
(B)Only S2
(C)Both S1&S2
(D)None of them

Q92. Which of following is/are correct?


S1: Every infinite set of strings over a single letter alphabet ∑={a} contains an infinite
Context free subset.
S2: Every infinite context-free set contains an infinite regular subset.
(A)Only S1
(B) Only S2
(C) Both S1&S2
(D) Neither S1 nor S2

BASIC THEORY OF COMPUTATION Page 82


Q93. Which of following is/are correct?
S1: If both L and 𝐿̅ are context-free, then L must be regular.
S2: There is a language L which is context-free but not regular such that 𝐿̅ is also
Context-free.
(A) Only S1 (B) Only S2
(C) Both S1&S2 (D) Neither S1 nor S2

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}

Q95. Which of following is/are correct statement?


(i) The language {0n1n U 0m1m| 0 ≤ n ≤ 1000,m>0 } is regular.
(ii) If a language is context-free, then it must be regular
(iii) If a language is regular, then it may be infinite.
(A)(i) and (ii) (B) (iii) only
(C)(i) and (iii) (D)(ii) and (iii)

Q96. The language L = {0i1i ⋃1i0i | i ≥ 0} is


(A) Regular (B) Deterministic CFL
(C) Non-Deterministic CFL (D) Not a CFL

Q97. Let L1 = {bnan | n ≥ 0} and L2 = {(ba)n | n ≥ 1}. What is |L1  L2|?


(A) 0 (B) 1 (C) 2 (D) infinite

Q98. Let L1 = {bn | n ≥ 1}. What is L1.L1?


(A) {bnbn | n ≥ 1} (B){bn| n >1}
(C) {bnbm | m, n >1} (D) (bb)+

Q99. Let L1 = {anbn : n >=0}. Then L1.L1 is:


(A){anbn: n >=0} (B){anbnambm : m, n >=0}
(C){a2nb2n: n >=0} (D){anbnanbn : n >=0}

BASIC THEORY OF COMPUTATION Page 83


Q100. Let L1 = {anbn : n >= 0}, and L2 = {bnan: n >=0}. Then L1.L2 is:
(A){anb2man: n, m>=0} (B){anbnambm: m, n >=0}
(C){amb2mam: m>=0} (D) {anbn+mam: m, n >=0}

Q101. Let L1 = {w | w* and w = wr,  = {a, b}} and L2= a*b*a* . Then L1 L2=

(A) {anbnam | n, m  0} (B) {anbman | n, m  0}


(C) {ambnan | n, m  0} (D) {anbnan | n, m  0}

Q102. Let L1 = {(ab)na | n ≥ 0} and L2 = {a(ba)n | n ≥ 0}. What is |L1  𝐿2


̅̅̅|?

(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 ≠ 𝑘}

Q105. Let L1 = {anbncp |n, p≥0} and L2 = {ambncn| m, n≥0} then L1  L2 is

(A)  (B) a*b*c*


(C) anbncn (D) {* - a*b*c*}

Q106. Let L1 = {w1w2 : |w1| = |w2| w1  (a, b)* and w2  (c, d)*} and L2 = {a, c}*.

Then L1  L2 will be:


(A)  (B) (a + c)*
(C) a*c* (D) {ancn | n>=0}

BASIC THEORY OF COMPUTATION Page 84


Q107. Suppose L1 is a context-free language and L2 is a non-context-free language, such that

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

Q108. Select the correct statement

(i) If L1 is context-free and L2 is regular, then L1 − L2 is context free.


(ii) If L1 is regular and L2 is context free, then L1 − L2 is context free.
(iii) L1 = L2 if and only if L1* = L2*
(A) Only i (B) ii & iii
(C) i & iii (D) None

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

Q111. How many of the following is/are correct statement?


(i) For any CFG G there's a CFG G0 such that G0 is not ambiguous and L (G) = L (G0).
(ii) The CFLs are closed under symmetric difference.
(iii) If L is context free, the even-length strings of L are context free.
(iv) If the prime-length strings of L are context free and the composite-length strings of
L are context free then L itself is context free.

BASIC THEORY OF COMPUTATION Page 85


Q112. Which one of the following statements is FALSE?
(A) There exist context-free languages such that all the context-free grammars
generating them are ambiguous.
(B) An unambiguous context free grammar always has a unique parse tree for each
string of the language generated by it
(C) Both deterministic and non-deterministic pushdown automata always accept the
same set of languages
(D) A finite set of string from one alphabet is always a context-free language.

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

Q114. Which of the following statement is/are true?

S1: Any regular language can be generated by a context-free grammar


S2: Some non-regular languages cannot be generated by any CFG
S3: The intersection of a CFL and regular set is a CFL
S4: All non-regular languages can be generated by CFGs
(A) S1, S2 and S4 only (B) S1, S3 and S4 only
(C) S2, S3 and S4 only (D) S1, S2 and S3 only

Q115. Which of the following statements is true?


(A) Both the regular languages and the context-free languages are closed under the
reverse operation.
(B) Neither the regular languages nor the context-free languages is closed under the
reverse operation.
(C) The regular languages are closed under the reverse operation but the context-free
Languages are not.
(D)The context-free languages are closed under the reverse operation but the regular
languages are not.

BASIC THEORY OF COMPUTATION Page 86


Q116. Which of the following is true?
(A) If L is context free, then L* must be regular.
(B) If L is an infinite context-free language, then in any context-free grammar generating
L there exists at least one recursive rule.
(C) Both a and b are true.
(D) None of these.
Q117. Which of the following statement is correct?

(A) If there is no pushdown automaton accepting L, then L cannot be regular.


(B) If L is accepted by a deterministic PDA, then L' (the complement of L) must be
Regular.
(C) If, for a given L in {a, b}*, there exist x, y, z, such that y  and xynz L for all n  0,
then L must be regular.
(D) If L is regular and L = L1  L2 for some L1 and L2, then at least one of L1 and L2
must be regular.

Q118. Which of the following is false?


(A) If L is an infinite context-free language, then there is some context-free grammar
generating L that has no rule of the form A  B, where A and B are nonterminal
symbols.
(B) Every context-free grammar can be converted into an equivalent regular grammar.
(C) Given a context-free grammar generating L, every string in L has a right-most
derivation.
(D) All are false.
Q119. Select the correct statements
(i) Language {0, 11} is context-free.
(ii) There is a deterministic Push-down automaton for the language of even length
Palindromes.
(iii) There are some ambiguous context-free grammars that can be disambiguated
(rewritten to become unambiguous).
(iv) Every context-free grammar can be disambiguated.
(A) i only (B) i and iii only
(C)ii and iii only (D)All are true

BASIC THEORY OF COMPUTATION Page 87


Q120. For every context-free grammar, there is a
(i) Language equivalent left-linear context-free grammar.
(ii) Language equivalent deterministic finite automaton.
(iii) Language equivalent push down automaton.
(iv) Language equivalent Turing machine.
(A) i and iii only (B) i, iii and iv only
(C)iii and iv only (D) all except i

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)=

{(q1, λ)}, 𝛿 (q1, λ, z) = {(q1, z)}

(b) 𝛿 (q0, λ, S) = {(q1, Sz)}, 𝛿 (q1, a, S) = {(q1, SB), (q1, SBB), (q1, B)}, 𝛿 (q1, b, B) =

{(q1, λ)}, 𝛿 (q1, λ, z) = {(qf, z)}

(c) 𝛿 (q0, λ, S) = {(q1, Sz)}, 𝛿 (q1, a, S) = {(q1, SB), (q1, SBB)}, 𝛿 (q1, b, B) = {(q1, λ)},

𝛿 (q1, λ, z) = {(qf, z)}

(d) None of the above

BASIC THEORY OF COMPUTATION Page 88


Q123. Consider the following grammar G: (Assume S is a starting symbol of G)

s aA | bBC | cC
Aa
B  bB | b
C cC | d

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) 𝛿 (𝑞0 , 𝜆, 𝑧) = {(q1 , Sz)}, 𝛿 (𝑞1 , 𝜆, 𝑆) = {(𝑞1 , aA), (𝑞1 , bBC), (𝑞1 , cC)},

𝛿 (𝑞1 , 𝜆, 𝐴) = {(𝑞1 , 𝑎)}, 𝛿 (𝑞1 , 𝜆, 𝐵) = {(𝑞1 , 𝑏𝐵), (𝑞1 , 𝑏)},

𝛿 (𝑞1 , 𝜆, 𝐶 ) = {(𝑞1 , 𝑐𝐶 ), (𝑞1 , 𝑐)}, 𝛿 (𝑞1 , 𝑎, 𝑎) = {(𝑞1 , 𝜆), },

𝛿 (𝑞1 , 𝑐, 𝑐) = {(𝑞1 , 𝜆), } 𝛿 (𝑞1 , 𝑑, 𝑑 ) = {(𝑞1 , 𝜆), }, 𝛿 (𝑞1 , 𝑏, 𝑏) = {(𝑞1 , 𝜆), }

(B) 𝛿 (𝑞0 , 𝜆, 𝑧) = {(q1 , Sz)}, 𝛿 (𝑞1 , 𝜆, 𝑆) = {(𝑞1 , aA), (𝑞1 , bBC), (𝑞1 , cC)},

𝛿 (𝑞1 , 𝜆, 𝐴) = {(𝑞1 , 𝑎)}, 𝛿 (𝑞1 , 𝜆, 𝐵) = {(𝑞1 , 𝑏𝐵), (𝑞1 , 𝑏)},

𝛿 (𝑞1 , 𝜆, 𝐶 ) = {(𝑞1 , 𝑐𝐶 ), (𝑞1 , 𝑑)}, 𝛿 (𝑞1 , 𝜆, 𝑧) = {(𝑞𝑓 , 𝑧)}

(C) 𝛿 (𝑞0 , 𝜆, 𝑧) = {(q1 , Sz)}, 𝛿 (𝑞1 , 𝜆, 𝑆) = {(𝑞1 , aA), (𝑞1 , bBC), (𝑞1 , cC)},

𝛿 (𝑞1 , 𝜆, 𝐴) = {(𝑞1 , 𝑎)}, 𝛿 (𝑞1 , 𝜆, 𝐵) = {(𝑞1 , 𝑏𝐵), (𝑞1 , 𝑏)},

𝛿 (𝑞1 , 𝜆, 𝐶 ) = {(𝑞1 , 𝑐𝐶 ), (𝑞1 , 𝑑)}, 𝛿 (𝑞1 , 𝜆, 𝑧) = {(𝑞𝑓 , 𝑧)},

𝛿 (𝑞1 , 𝑎, 𝑎) = {(𝑞1 , 𝜆), } , 𝛿 (𝑞1 , 𝑏, 𝑏 ) = {(𝑞1 , 𝜆), }, 𝛿 (𝑞1 , 𝑐, 𝑐) = {(𝑞1 , 𝜆), }

𝛿 (𝑞1 , 𝑑, 𝑑 ) = {(𝑞1 , 𝜆), }

(D) none of the above

BASIC THEORY OF COMPUTATION Page 89


PDA of grammar to string
Q124. Consider the following PDA M (Q, Σ, , 𝛿, z, F) for a grammar G:
M is defined by Q = {q0, q1, qf}, Σ = {a, b}, = {𝑆, 𝐴, 𝐵, 𝑧}, F = {qf} and the transition
rules (𝛿) are:
𝛿 (𝑞0 , 𝜆, 𝑧) = (𝑞1 , 𝑆𝑧), 𝛿 (𝑞1 , 𝜆, 𝑆) = {(𝑞1 , 𝑎𝐴), (𝑞1 , 𝑏𝐵)},
𝛿 (𝑞1 , 𝜆, 𝐴) = {(𝑞1 , 𝑎𝐴), (𝑞1 , 𝑎)}, 𝛿 (𝑞1 , 𝜆, 𝐵) = {(𝑞1 , 𝑏𝐵), (𝑞1 , 𝑏)},
𝛿 (𝑞1 , 𝑎, 𝑎) = (𝑞1 , 𝜆), 𝛿 (𝑞1 , 𝑏, 𝑏) = (𝑞1 , 𝜆),
𝛿 (𝑞1 , 𝜆, 𝑧) = (𝑞𝑓 , 𝑧)
Which of the following string is not accepted by M?
(A) aaaaa (B) b
(C) bbaa (D) bbb
Data for next three questions: Consider the following PDA M (Q, Σ, , 𝛿, z, F) for a
grammar G: M is defined by Q = {q0, q1, qf}, Σ = {a, b}, = {𝑆, 𝐴, 𝐵, 𝐶, 𝑧}, F = {qf} and the
transition rules (𝛿) are:
𝛿 (𝑞0 , 𝜆, 𝑧) = {(𝑞1 , 𝑆𝑧)}, 𝛿 (𝑞1 , 𝑎, 𝑆) = {(𝑞1 , 𝐴)},
𝛿 (𝑞1 , 𝑎, 𝐴) = {(𝑞1 , 𝐴𝐵𝐶 ), (𝑞1 , 𝜆)}, 𝛿 (𝑞1 , 𝑏, 𝐵) = {(𝑞1 , 𝜆)},
𝛿 (𝑞1 , 𝑏, 𝐴) = {(𝑞1 , 𝐵)}, 𝛿 (𝑞1 , 𝑐, 𝐶 ) = {(𝑞1 , 𝜆)}, 𝛿 (𝑞1 , 𝜆, 𝑧) = (𝑞𝑓 , 𝑧)
Q125. How many of the following string is/are accepted by M? _______
(i) aaabc (ii) aabbc (iii) aabc (iv) aac (v) aa

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, Bb
(c) S  aA, A  aABC | bB | a, B  b, Cc
(d) S  aS | aSbc | bb | a

Q127. Which of the following language is equivalent to language generated by G?


(A) L = {𝑎𝑎∗ (𝑎 + 𝑏𝑏)(𝑏𝑐)∗ }
(B) L = {𝑎𝑎𝑘 𝑤 (𝑏𝑐)𝑘 | 𝑘 ≥ 0 𝑎𝑛𝑑 𝑤 = {𝑎, 𝑏𝑏}}
(C) L = {𝑎𝑘 𝑎𝑏𝑏(𝑏𝑐)𝑘 | 𝑘 ≥ 0}
(D) None of these

BASIC THEORY OF COMPUTATION Page 90


PDA to Grammar
Q128. Consider the following PDA M (Q, Σ, , 𝛿, z

Which of the following grammar is/are equivalent to given PDA?


(A) S  0S1 | λ (B) S  0S1 | 01
(C) S  0S1 | 0011 (D) None of the above
(CNF and GNF)
Q129. Which of the following grammar doesn’t have useless production?

(A) S  aAa| BC, A  aa |Aa, BcC | c


(B) S aAb | Bc | aA, A  BC, BbB |AC, C cC| c
(C)S ABb | aA, A  BC| c, BbB |AC, C cC| CC
(D) S aSb | λ | aA, A BC|λ, BbB |AC|b, C cC| λ

Q130. Consider following grammar G with productions

S aS | BA | CD, A a| Da, Baa|aC, CaCb| cC|CC


After removing all useless production from G, which of the following grammar is
equivalent to G?
(A) S aS | a | aa (B)S aS| aaa
(C) S aS|aA , A aa (D)b& c

Q131. Consider following grammar G with productions

S Aa | C, A bA| B,B aB | C | b, C cC | c


After removing all unit-production from G, which of the following grammar is
Equivalent to G?
(A) S Aa | c, A bA | aB | cC | b | c, B aB | cC | b | c, C cC | c
(B)S Aa | cC | c, A bA | aB | cC | b | c, B aB | cC | b | c
(C)S Aa | cC | c, A bA | aB| b | c, B aB | cC | b | c, C cC | c
(D) S Aa | cC | c, A bA | aB | cC | b | c, B aB | cC | b | c, C cC | c

BASIC THEORY OF COMPUTATION Page 91


Q132. Consider following grammar G with productions

S AaB | aaB,A  λ, B bbA| λ


After removing all λ-production from G, which of the following grammar is
equivalent to G?
(A)S aB | aaB,B  bb (B)S  a | aaB| aa,B  bb
(C)S aB | aaB| bb,B  bb| λ (D) S aB | aaB| a | aa,B  bb

Q133. Consider following grammar G with productions

S aA | aBB| AB, A aaA| λ, B bB| bbC, CB|λ


After removing all unit-production, all useless production and all λ-production from
G, which of the following grammar is equivalent to G?
(A) S aA | aBB| AB| a| bb, A aaA| aa, B bB| bbC| bb, CbB|bbC| bb
(B) S aA | aBB| AB| bB| bbC| a| bb, A aaA| aa, B bB| bbB| bb,
(C) S aA | aBB| AB| bB| bbC| a| bb, A aaA| aa, B bB|bb, CbB|bbC| bb
(D) S  aA | aBB| AB| bB| bbC| a| bb|aB, A aaA| aa, B bB| bbC| bb,
CbB| bbC|b

Q134. Convert the following grammar into Chomsky normal form:

S ABa| bC, Aa|λ, Bb|C, Cc|λ


(A)S ABa| bC|Ba|Aa|a|b, Aa, Bb|c, Cc
(B) S  DA |BC|BA|AA|a|b, Aa, Bb, Cc, DBA
(C)S  AD |BC|D|AA|a|b, Aa, Bb, Cc, DAB
(D) S  DA |BC|BA|AA|a|b, Aa, Bb|c, Cc, DAB

Q135. Convert the following grammar G into Greibach normal form:

S  abc | aSb| aaSc | bSc


(A)S  aABC | aSB | AaSc | bSc, Aa, Bb, Cc,
(B)S  aBC | aSB | aASc | bSC, Aa, Bb, Cc
(C) S  aBC | aSB | aASC | bSC, Aa, Bb, Cc
(D)S  aABC| aSb | aASC | bSC, Aa, Bb, Cc

BASIC THEORY OF COMPUTATION Page 92


Q136. Let G be a grammar in Chomsky Normal Form. Let w1,w2  L(G) such that|w1| =

|w2|. Which of the following is true?


(A) Any derivation of w1 has exactly the same number of steps as any derivation of w2.
(B) Some derivations of w1 may be shorter than some derivations of w2.
(C) Different derivations of w1 have different lengths.
(D) Some derivations of w1 maybe longer than some derivations of w2.
Q137. [MSQ]
Which of the following rule(s) doesn’t belong to CNF of any CFG?
(A) S → BC
(B) B → Bc
(C) B → a
(D) S → B
For the next three questions, consider the following grammar:
G1 = ({S, T}, {a, b}, {S → aT, T → aT, T→ b}, S)
G2 = ({S, S1, S2}, {a, b}, {S → aS1, S1 → aS1, S1 → bS2, S2 →a}, S)
G3 = ({S, S1, A, B}, {a, b}, {S → AS1, S1 → AS1, S1 → bB, A → a, B → b}, S)
G4 = ({S, S1, S2, A, B}, {a, b}, {S → AS1|, S1 → AS1|BS2, A → a, B → b, S2→a}, S)
Q138. Which of the above grammars are regular grammars?

(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

BASIC THEORY OF COMPUTATION Page 93


Q141. Which of the following sets of productions is not in Chomsky normal form?
G1 : S  AB A  AB|a B  Ba|b
G2 : S  AB A  AB|a B  BA|b
G3 : S A|B A AB|a B  BA|b
(A) G2 (B) G1, G2, G3
(C)G2 and G3 (D) G1 and G3
Q142. Consider a grammar G

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:

For each of following questions select the correct one.


Q143. The cell [2, 1] contains

(A) {B} (B) {A, B}


(C) ∅ (D) {S, A}

BASIC THEORY OF COMPUTATION Page 94


Q144. The cell [3, 1] contains
(A) {B} (B) {A, B}
(C) ∅ (D) {S, A}

Q145. The cell [3, 2] contains


(A) {B} (B) {A, B}
(C) ∅ (D) {S, A}

Q146. The cell [5, 3] contains


(A) {B} (B) {A, C}
(C) ∅ (D) {S, A}

Pumping lemma for CFL


Q147. Consider the CFG used in the proof of the pumping lemma: we chose a string long
enough so that it is accepted by the CFG and repeats a variable. What if such a string
does not exist for this CFG?
(A) There is no possibility of this happening: there always is such a string.
(B) The CFG’s language must be finite.
(C) The CFG’s language may or may not be infinite.
(D) Then there is at most 1 variable that produces a single terminal in the CFG.

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

BASIC THEORY OF COMPUTATION Page 95


Q149. Consider the language L = {aibjaibj | i, j >= 0}. Consider the following “proof" that L
satisfies the pumping lemma. Let p be the pumping length. Choose Z = apbapb.
Consider a division of Z, where u = ap-1, v = a, w = b, x = a and y = ap-1b. Clearly
uviwxiy is in L for every i.
(A) This is an incorrect proof because all divisions of Z have not been considered.
(B) This is an incorrect proof because all possible Z have not been considered.
(C) This is a correct proof.
(D)None of above
Q150. Consider the language L = {anbncn | n >= 0}. Consider the following “proof" that L does
not satisfy the pumping lemma. Let p >= 1 be the pumping length. Choose z = apbpcp.
Consider the division of z, where u = , v = a, w = , x = , and y = ap-1bpcp.
Clearly uv0wx0y is not in L.
(A) This is an incorrect proof because all divisions of z have not been considered.
(B) This is an incorrect proof because all possible z have not been considered.
(C) This is a correct proof.
(D)None of above
Q151. Select the correct statements

(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?

(I) For context-free grammar G find if string w  G


(II) For context-free grammar G find if L (G) = 
(III) For context-free grammar G find if L (G) is infinite.
(A) Only I (B) Only I&II
(C) I, II & III (D) Only II & III

BASIC THEORY OF COMPUTATION Page 96


Q153. Which of the following language is/are Turing decidable?

1. L = {<G1, G2> | G1 & G2 are regular grammar and L(G1)  L(G2)}


2. L = {<G, R> | G is a CFG & R is a regular expression and L(G)  L(R)}
3. L = {<G, R> | G is a CFG & R is a regular expression and L(R)  L(G)}
(A) 1 only (B) 1 & 2 only
(C) 2 & 3 only (D) 1 & 3 only

Q154. Which of the following language is/are NOT Turing decidable?

1. L = {<G1, G2> | G1 & G2 are CFG and L(G1)  L(G2) is empty}


2. L = {<G1, G2> | G1 & G2 are CFG and L(G1)  L(G2) is CFL}
3. L = {<G1, G2> | G1 & G2 are CFG and L(G1)  L(G2) is regular}
4. L = {<G1, G2> | G1 & G2 are DCFG and L(G1)  L(G2) is empty}
(A) 1 & 2 only (B) 1, 2 & 3 only
(C) 1, 2 & 4 only (D) All the above

Q155. Which of the following language is/are not decidable?

1. L = {<G> | G is a CFG and λ  L(G)}


2. L = {<G, w> | G is a CFG and w  L(G)}
3. L = {<G> | G is a CFG and G is unambiguous}
4. L = {<G> | G is a CFG and L(G)  ∑*}
(A) 1 & 2 only (B) 3 & 4 only
(C) 3 only (D) 4 only
Q156. [MSQ]
Which of the following languages are undecidable?
(A) L = {<G, > | L (G) = *; where G is a CFG and  is finite set of alphabets}
(B) L = {<G, R> | L (G) = R; where G is CFG and R is regular language}
(C) L = {<G1, G2> | L (G1) = L (G2); where G1 and G2 are two CFG’s}
(D) L = {<G1, G2> | L (G1)  L (G2); where G1 and G2 are two CFG’s}

BASIC THEORY OF COMPUTATION Page 97


TURING MACHINE
Q1. The language accepted by the following Turing machine is:

(A)a* (B)a*ba*
(C)ba* (D)aba*

Q2. Given a Turing Machine M, what’s L (M)?

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


(C) (0+1)* (D) 

Q3. Given a Turing Machine M, what’s L (M)?

(A) (b +ab)*aa (B) b*aa(a+b)*


(C) b*(ab)*aa(a+b)* (D) (b+ab)*aa(a+b)*

Q4. Given a Turing Machine M, what’s L (M)?

(A)L(M) = (a+b)*aa(a+b)* (B)L(M) = (a+b)*aa


(C)L(M) = b*ab*a(a+b)* (D)L(M) = b*a(a+b)*a

BASIC THEORY OF COMPUTATION Page 98


Q5. Consider the following Turing Machine:
M =({q0,q1,q2,qacc,qrej},{a,b},{a,b,B} ,𝛿,q0,qacc,qrej),where
𝛿 (q0, a) = (q1, b, R)
𝛿 (q1, b) = (q2 , a, L)
𝛿 (q2, b)= (q0, b, R)
𝛿 (q1, B)= (qacc , B,R)
As always, we assume for cases not mentioned above 𝛿 (q , a)=(qrej , B , R) What can we
say about the Turing machine M?
(A) M halts on all inputs
(B) M never halts on some inputs
(C) M does not halt on any input
(D) None of these
Q6. What language does the following Turing Machine (TM) accept?
M = (Q = {q0, q1, q2}, Σ = {a, b}, Γ = {a, b, B}, δ, q0, B, F = {q2}); where the transition
function δ is given by
δ(q0, a) = {(q0, a, R)}
δ(q0, b) = {(q1, b, R)}
δ(q1, B) = {(q2, B, R)}
δ (q, x) = stop everywhere else
(A) a*b (B) aa*b
(C) ∅ (D) a*b(a+b)*
Q7. Consider the Turing machine M = (Q, Σ, Γ, δ, q0, qacc, qrej); where
• Q = {q0, q1, q2, q3, qacc, qrej}
• Σ = {0, 1}, and Γ = {0, 1, A, B, t}
• δ is given as follows:
δ(q0, 0) = (q1, A, R) δ(q0, B) = (q3, B, R)
δ(q1, 0) = (q1, 0, R) δ(q1, B) = (q1, B, R)
δ(q1, 1) = (q2, B, L) δ(q2, B) = (q2, B, L)
δ(q2, 0) = (q2, 0, L) δ(q2, A) = (q0, A, R)
δ(q3, B) = (q3, B, R) δ(q3, t) = (qacc, t, R)
In all other cases, δ(q, X) = (qrej, t, R). So for example, δ(q0, 1) = (qrej, t, R).
How many of the following strings are rejected by M? __________
i. 10001 ii. 111000 iii. 0010 iv. 10100 v. 101010

BASIC THEORY OF COMPUTATION Page 99


Q8. A Turing machine M with start state q0 and accepting state qf has the following transition
function:
δ(q, a) 0 1 B
q0 (q1 ,0,R) - -
q1 - (q0, 1, R) (qf , B, R)
qf - - -
Which of the following strings are accepted by TM?
(A) 1110 (B) 0110
(C) 01011 (D) 0101

Q9. The language accepted by the following Turing machine is


M1 = ({q0, qaccept, qreject}, {0, 1}, {0, 1,}, δ, q0, q accept, q reject)
δ(q0, 0) = (qaccept, 0, R)
δ(q0, 1) = (qreject, 1, R)
δ(q0,) = (qreject, 1, R).
(A) 0+ 1* (B)0* 1*
(C) (0+1)* (D) 0 (0*1*)*
Q10. Consider the Turing machine M = (Q, Σ, Γ, δ, q0, qacc, qrej) where
• Q = {q0, q1, q2, q3, qacc, qrej}
• Σ = {0, 1}, and Γ = {0, 1, A, B, t}
• δ is given as follows
δ(q0, 0) = (q1, A, R) δ(q0, B) = (q3, B, R)
δ(q1, 0) = (q1, 0, R) δ(q1, B) = (q1, B, R)
δ(q1, 1) = (q2, B, L) δ(q2, B) = (q2, B, L)
δ(q2, 0) = (q2, 0, L) δ(q2, A) = (q0, A, R)
δ(q3, B) = (q3, B, R) δ(q3, t) = (qacc, t, R)
In all other cases, δ(q, X) = (qrej, t, R). So for example, δ(q0, 1) = (qrej, t, R).
Which of the following strings are accepted by M?
i) 0011 ii)0101 iii)01 iv)10100 v) 1010
(A) i and iii (B) iii and v
(C) i, ii and iv (D) ii and iii

BASIC THEORY OF COMPUTATION Page 100


Q11. The following Turing machine

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

Q12. The outcome of the computation of M on input ‘00’ is


(A) ACCEPT (B) REJECT
(C) LOOP (D) None

Q13. The outcome of the computation of M on input ‘01’ is


(A)ACCEPT (B) REJECT
(C) LOOP (D) None

BASIC THEORY OF COMPUTATION Page 101


For Next Three Questions: Consider the Turing machine:

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.

Q17. What is the smallest number of states that a TM could have?


(A) 0 (B) 1
(C) 2 (D) 3

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

BASIC THEORY OF COMPUTATION Page 102


Q19. Suppose that a Turing Machine is run on an input. Which of the following is false?
(A) Infinitely many configurations of the machine can occur.
(B) If a configuration of the machine arises twice in a computation on this input, the
machine enters an infinite loop.
(C) Every configuration contains exactly one state of the machine.
(D) A configuration of the machine might have infinite length because the tape is infinite.
Q20. 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
Q21. What language is accepted by the Turing machine whose transition graph is shown
below?

(A) The language of the machine is therefore ab*b


(B) The language of the machine is therefore bb*a(a+b)*
(C) The language of the machine is therefore ab* + bb*a(a+b)*
(D) The language of the machine is therefore ab*b + bb*a(a+b)*
Q22. [MSQ]
The language accepted by the following Turing machine is

(A) L = {anbman+m : n ≥ 0, m ≥ 1} (B) L = {ambnam+n : m ≥ 0, n ≥ 1}


(C) L = {anbman+m : n ≥ 1, m ≥ 1} (D) L = {anbman+m : n ≥ 0, m ≥ 0}

BASIC THEORY OF COMPUTATION Page 103


Q23. [MSQ]
Which language does the following TM accept?

(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},

The language accepted by given Turing machine is


(A)L = {aibj | i ≥ 0, j= i}
(B) L = {aibj | i ≥ 0, j < i}
(C) L = {aibj | i ≥ 0, j ≤ i}
(D) L = {aibj | i ≥ 0, j ≥ i}

BASIC THEORY OF COMPUTATION Page 104


Q25. The following language
L1 = {<M>|M is a TM and there exists an input on which M halts in less than |<M>|
steps} is:
(A) recursive
(B) recursively enumerable but not recursive
(C) not recursively enumerable
(D) Regular

Q26. The language L2 = {<M>|M is a TM and |L(M)| ≤ 3} is:


(A) recursive
(B) recursively numerable but not recursive
(C) not recursively enumerable
(D) none of the above

Q27. The following language

L2 = {<M>|M is a TM and |L(M)| ≥ 3} is:


(A) Recursive
(B) recursively enumerable but not recursive
(C) not recursively enumerable
(D) none of the above

Q28. The following language


L4 = {<M>|M is a TM that accepts all even numbers}is:
(A) recursive
(B) recursively enumerable but not recursive
(C) not recursively enumerable
(D) none of these
Q29. The following language
L1 = {<M>|M is a TM and L(M) is finite}is:
(A) recursive
(B) recursively enumerable but not recursive
(C) not recursively enumerable
(D) context-Sensitive but not CFL

BASIC THEORY OF COMPUTATION Page 105


Q30. The following language
L1 = {<M>| there exist x, y ∈ Σ*such that either x ∈L(M) or y ∉ L(M)}.
(A) recursive
(B) recursively enumerable but not recursive
(C) not recursively enumerable
(D) context-Sensitive but not CFL

Q31. The following language

L1 = {<M, x, k>|M is a TM, and M does not halt on x within k steps}is:


(A) Recursive
(B) Recursively enumerable but not recursive
(C) Not recursively enumerable
(D) Not recursive

Q32. The following language

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

BASIC THEORY OF COMPUTATION Page 106


Data for next ten questions: Consider the following languages (Q34 to 43 - 2020)
L1 = {<M> | M is a TM and M accepts at most 225 distinct inputs}
L2 = {<M> | M is a TM and M accepts at least 225 distinct inputs}
L3 = {<M> | M is a TM and M accepts exactly 225 distinct inputs}
L4 = {<M, w> | M is a TM and M doesn’t halt on ‘w’}.
L5 = {<M, w> | M is a TM and M halts on ‘w’}
L6 = {<M, w> | M is a TM and M accepts ‘w’}
L7 = {<M, w> | M is a TM and M rejects ‘w’}
L8 = {<M> | M is a TM and M has exactly five states}
L9 = {<M> | M is a TM and M has exactly three tapes}
L10 = {<M> | M is a TM and L(M) = {001, 100}}
Q34. Then L1 is
(A) Recursive (B) RE (C) Not RE (D) finite

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

(A) RE (B) Co-RE (C) Not RE (D) Both b & c

BASIC THEORY OF COMPUTATION Page 107


Q44. [MSQ]
The language ADFA = {<D, w> | D is DFA that accepts w}is
(A) Decidable (B) Turing Recognizable
(C) Not Turing Recognizable (D) None

Q45. The language ACFG = {<G>|G is CFG and L (G) =  ∗}is

(A) Decidable (B) Turing Recognizable


(C) Not Turing Recognizable (D) None
Q46. [MSQ]
The language ECFG = {<G> | G is a CFG and L (G) = ∅} is
(A) Decidable (B) Turing Recognizable
(C) Not Turing Recognizable (D) None

Q47. EQTM = {<M1, M2> | M1, M2 are TMs with L(M1) = L(M2)}?
(A) Decidable (B) Turing Recognizable
(C) Not Turing Recognizable (D) None

Q48. EQDFA={<M1,M2> | M1,M2 are DFAs with L(M1)=L(M2)}?

(A) Decidable (B) Turing Recognizable


(C) Not Turing Recognizable (D) None
Q49. Consider the following language
L = {<M> : M is TM such that L(M) = ∅}.
(A) Turing recognizable (B) Turing decidable
(C) Not Turing recognizable (D) CO-RE

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

BASIC THEORY OF COMPUTATION Page 108


Data for next two questions: Let M be a standard Turing machine (with a single one-track tape
and a single head) that decides the regular language 0*1*.
Q51. Which of the following must be true?
1. Given an empty initial tape, M eventually halts.
2. M accepts the string 1111.
3. M rejects the string 0110.
4. M moves its head to the right at least once, given input 1100.
(A) 2 & 3 only
(B) 1 & 4 only
(C) 2, 3 & 4 only
(D) All are true
Q52. Which of the following is /are not always true?

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

BASIC THEORY OF COMPUTATION Page 109


Q54. Which of the following problems about context-free grammars are undecidable?
1. Given a context-free grammar G, is ε ∈ L (G)?
2. Given a context-free grammar G, is {ε} = L (G)?
3. Given two context-free grammars G1 and G2, is L (G1) ⊆ L (G2).
(A) 1only (B) 2 only
(C) 3 only (D) 1, 2 and 3
Data for next two questions: Let G1 and G2 are CFGs and R denotes given regular expression.
Q55. Which of the following problems are undecidable?
1. L (G1) ∩ L (G2) ≠∅ 2. L (G1) ≠ L (G2) 3. L (G1) ≠ L (R)
(A) 1only (B) 2 only
(C) 1, 3 only (D) 1, 2 and 3
Q56. Which of the following problems is/are decidable?
1. L (G2) – L (G1) ≠∅?
2. L (R) – L (G1) ≠∅
3. L (R) = finite
4. L (G1 U G2) = Σ*
(A) 1 & 2 only (B) 3 & 4 only
(C) 1, 3 only (D) 3 only
Q57. How many of the following languages are Un-decidable? ________
1. L = {<M> | M is a TM and M accepts at least one string over {0, 1}}.
2. L = {<M> | M is a TM and M accept all strings over {0, 1}}.
3. L = {<M> | M is a TM and M accepts “Hello”}.
4. L = {<M1, M2> | M1 and M2 are TM’s and M1 accept more strings than M2}.
5. L = {<M> | M is a TM and M take more than 1000 steps to process input w}.
6. L = {<M1, M2> | M1 and M2 are TM’s and M1 take more steps than M2 to process input
w}
Q58. Suppose that a Turing Machine is run on an input. Which of the following is false?
(A) Infinitely many configurations of the machine can occur.
(B) If a configuration of the machine arises twice in a computation on this input, the
machine enters an infinite loop.
(C) Every configuration contains exactly one state of the machine.
(D) A configuration of the machine might have infinite length because the tape is infinite

BASIC THEORY OF COMPUTATION Page 110


Q59. Which of the following statement is/are true?
i. There is a language that is decidable and its complement is not decidable.
ii. There is a language that is recognizable and its complement is not recognizable.
iii. The problem of determining whether a TM accepts at least 7 strings is un decidable.
iv. The problem of determining whether a TM has at least 7 states is un decidable.
(A) i and iv only (B) ii and iii only
(C) i, ii and iii only (D) iii and iv only

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

Q62. Which of the following statement/s is/are true?


1. If A is regular and B is regular, then A U Bc is always Recursive.
2. If A is context-free and B is regular, then A U Bc is always Recursively enumerable
3. If A is regular and B is context-free, then A Bc is regular.
4. If A is recursive and B is recursive, then A Bc is always Recursively enumerable but
not recursive.
(A) 1 only (B) 1 & 2 only
(C) 1, 2 & 4 only (D) All the above

BASIC THEORY OF COMPUTATION Page 111


Q63. Which of the following statement/s is/are false?
1. If A is recursive and B is Recursively enumerable (RE), then A U Bc is Recursively
enumerable.
2. If A is recursively enumerable and B is recursive then A U Bc is Recursive.
3. If A is regular language and B is non-regular language then A  Bc is always regular.
4. If A is RE and their complement is also RE then A is always Turing decidable.
(A) 1 & 2 only (B) 1, 2 & 3 only
(C) 4 only (D) All the above

Q64. Which of the following statements about formal languages is false?

(A) Every recursive language is recursively enumerable.


(B) The complement of a recursive language is recursive.
(C) The complement of a recursively enumerable language is recursively enumerable.
(D) The union of two recursively enumerable languages is recursively enumerable

Q65. Which of the following is/are not decidable?

1.ACFG = {<G, w> : G is a CFG that generates string w}


2.ECFG = {<G> : G is a CFG and L(G) = }
3. DCFG= {<G> : G is a CFG and G is ambiguous}
4.UCFG={<G>: L(G) ≠* }
(A) 3 and 4 only (B) 1 and 3 only
(C)1, 2 and 4 only (D) 2, 3 and 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

BASIC THEORY OF COMPUTATION Page 112


Q67. Consider the following sets of languages over the alphabet {0, 1}:
• LDTM is the set of all languages L ⊆ {0, 1} ∗ such that L is accepted by at least one
deterministic Turing machine.
• LNTM is the set of all languages L ⊆ {0, 1} ∗ such that L is accepted by at least one non-
deterministic Turing machine.
Which of the following statements is/are true?
(A) LDTM LNTM
(B) LDTM LNTM
(C) LDTM = LNTM
(D) Undecidable problem

Q68. Which of the following statements are correct?

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

Q69. Which of the following statements are correct?


i) DFA reads its input fully before accepting a string.
ii) A multi-tape TM is equivalent to a single tape TM.
iii) A DTM may accept a string without reading its input.
iv) The number of configurations of an LBA is fixed by its number of states Q.
(A)ii and iii only
(B)ii only
(C) i, ii and iii
(D)All the above

BASIC THEORY OF COMPUTATION Page 113


Q70. State which of the following statements are true?
(I) If A is context-free, then A is Turing-recognizable.
(II) Every language is Turing-recognizable.
(III) For a Turing machine M and a string w, M either accepts or rejects w.
(IV) The language ((01 ∪ 10)*0 ∪ 1)* is countable.
(V) If language A is recognized by a 14-tape nondeterministic Turing machine, then
there is a single-tape deterministic Turing machine that also recognizes A.
(A) I, IV and V only (B) I and V only
(C) All except II (D) All the above

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

Q71. L1 U L2 = * is decidable for


i) regular languages ii) context-free languages
iii) recursive languages iv) recursively enumerable languages
(A)Only i & ii (B)Only i
(C)Only ii & iv (D)Only iii & iv

Q72. x  L1 is decidable for

i) regular languages ii) context-free languages


iii) recursive languages iv) recursively enumerable languages
(A)Only ii & iii (B)Only i, ii & iii
(C)Only iii & iv (D)Only I & iv

Q73. R  L1 is decidable for


i) regular languages ii) context-free languages
iii) recursive languages iv) recursively enumerable languages
(A)Only ii & iii (B)Only I
(C)Only ii & iv (D)Only iii & iv

BASIC THEORY OF COMPUTATION Page 114


Q74. L1 − R = ∅ is decidable for
i) regular languages ii) context-free languages
iii) recursive languages iv) recursively enumerable languages
(A)Only ii (B)Only i & ii
(C)Only iii &iv (D)Only ii &iii

Q75. y  L1, |y| < 5 is decidable for

i)regular languages ii) context-free languages


iii) recursive languages iv) recursively enumerable languages
(A) Only iii & iv (B) Only ii & iii
(C) Only i, ii & iii (D) Only i & iv

Q76. Which of following is/are correct?

S1: Deterministic two-stack automata are as powerful as Turing machines.


S2: {⟨M⟩ | M is a Turing machine and M does not accept 101} is recursively enumerable
(A)Only S1 (B)Only S2
(C)Both S1&S2 (D)None of them

Q77. Which of the following problem is undecidable?


(A) membership problem for CFL
(B) membership problem for regular sets
(C) membership problem for CSL
(D)membership problem for type 0 languages

Q78. Which of the following is/are true about uncountable set?


(i) If A is a subset of B and A is uncountable, then so is B.
(ii) If A is infinite (even countably infinite) then the power set of A is uncountable
(iii) If A is uncountable and B is any set, then the union A U B is also uncountable.
(iv) If A is uncountable and B is any set, then the Cartesian product A x B is also
uncountable.
(A) i, ii only (B) iii, iv only
(C)ii, iii, iv only (D)All the above

BASIC THEORY OF COMPUTATION Page 115


Q79. Which of the following statement is/are True?
1. The language (0 ∪ 1)* is countable.
2. The set of all possible language over {a, b} is countable.
3. The set of recursively enumerable languages is countable.
4. The Cartesian product of a finite number of countable set is countable.
(A) 1 & 4 only (B) 2 & 3 only
(C) 1, 3 & 4 only (D) All the above

Q80. Which of the following statement is/are NOT true?


1. Set of all prime numbers is countable.
2. Set of rational numbers is uncountable.
3. Set of Binary Sequences is uncountable.
4. Set of real Numbers is uncountable.
5. Set of all integers is countable.
(A) 1 & 2 only (B) 3, 4 & 5 only
(C) 2 only (D) 1, 2 & 3 only

Q81. Which of the following statement is/are true?

1. The set of all pairs, (i, j) with i, j positive integers, is countable.


2. The set of all triplets, (i, j, k) with i, j, k positive integers, is countable.
(A) 1 only (B) 2 only
(C) Both 1 & 2 (D) Neither 1 nor 2

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.

Q83. Which of the following statement is/are true?


1. Subset of infinite countable set is countable.
2. Superset of countable set may be uncountable.
3. There exists a countably infinite set which is subset of an uncountable set.
4. Power set of countably infinite set is always countable.
(A) 1 & 2 only (B) 3 & 4 only
(C) 1, 2 & 3 only (D) All the above

BASIC THEORY OF COMPUTATION Page 116


Closure Properties

BASIC THEORY OF COMPUTATION Page 117


List of theorems:
1. The class of regular languages is closed under union.
2. The class of regular languages is closed under concatenation.
3. Every NFA has an equivalent DFA.
4. The class of regular languages is closed under Kleene - star.
5. (Kleene’s theorem) Language A is regular if A has a regular expression.
6. If A is finite language, then A is regular.
7. The class of regular languages is closed under intersection.
8. The class of regular languages is closed under complementation.
9. If A is regular language, then ∃ number p where, if s ∈ A with |s| > = p, then ∃ strings x,
y, z such that
s = xyz and (1) xyiz ∈ A for each i > = 0, (2) |y | > 0, and (3) |xy | < = p
10. Every CFL can be described by a CFG G = (V, , R, S) in Chomsky normal form, i.e., each
rule in G has one of two form s: A → BC or A → x, where (A Є V), (B, C Є V  {S}), x Є ,
and we also allow the rule S → Є.
11. If A is a regular language, then A is also a CFL.
12. A language is context free iff some PDA recognizes it.
13. (Pumping lemma for CFLs) For every CFL L, ∃ pumping length p such that ∀ strings s Є L
with |s| > = p, we can writes s = uvxyz with (1) uv ixyiz Є L ∀ i > = 0, (2) |v y| > = 1, (3)
|vxy | < = p.
14. The class of CFLs is closed under union.
15. The class of CFLs is close d under concatenation.
16. The class of CFLs is closed under Kleene- star.
17. For e very multi- tape TM M , there is a single- tape TM M such that L (M) = L (M’)
18. Every NTM has an equivalent deterministic TM.
19. Language L is Turing-recognizable if an NTM recognizes it.
20. A language is enumerable if some enumerator enumerates it
Church-Turing Thesis The information of algorithm is the same as Turing machine algorithm
1. ADFA = {<B, w> | B is a DFA that accepts string w} is Turing-decidable.
2. ANFA = {<B, w> | B is an NFA that accepts string w} is Turing-decidable.
3. AREX = {<R, w> | R is a regular expression that generates string w} is Turing-decidable.
4. EDFA = {<B> | B is a DFA with L (B) = Ø} is Turing-decidable.

BASIC THEORY OF COMPUTATION Page 118


5. EQDFA = {<A, B> | A and B are DFAS with L (A) = L (B)} is Turing-decidable
6. ACFG= {<G, w> | G is a CFG that generates string w} is Turing-decidable.
7. E= {G | G is a CFG with L (G) = Ø} is Turing-decidable.
8. Every CFL is Turing-decidable
9. ATM = {<M, w> | M is a TM that accepts string w} is undecidable.
10. The set R of all real numbers is uncountable
11. Some languages are not Turing-recognizable.
12. A language is decidable if it is both Turing-recognizable and co-Turing- recognizable.
13. ATM (bar) is not Turing-recognizable.
14. HALTTM = {<M, w> | M is a TM that halts on w} is undecidable.
15. ETMTM= {<M> | M is a TM with L (M) = Ø} is undecidable.
16. REGTM= {<M> is a TM and L (M) is regular} is undecidable.
17. EQTM= {<M1, M2> | M1, M2 are TMs with L (M1) = L (M2)} is undecidable.
18. (Rice’s Thm.) Let P be any subset of the class of Turing-recognizable languages such that
P ≠ Ø and
P (bar) ≠ Ø. Then LP = {<M> | L (M) ∈ P} is undecidable.
19. If A < =m B and B is Turing-decidable, then A is Turing-decidable.
20. If A < =m B and A is undecidable, then B is undecidable.
21. If A < =m B and B is Turing-recognizable, then A is Turing-recognizable.
22. If A < =m B and A is not Turing-recognizable, then B is not Turing-recognizable.
23. ETM= {<M> is a TM with L (M) = Ø} is not Turing-recognizable.
24. EQTM= {<M1, M2> | M1, M2 are TMs with L (M1) = L (M2)} is neither Turing- recognizable
nor co-Turing-recognizable.
25. Let t (n) be a function with t (n) > = n. Then any t (n)-time multi-tape TM has an equivalent
O (t2 (n))-time single-tape TM.
26. Let t (n) be a function with t (n) > = n. Then any t (n)-time NTM has an equivalent 2O (t (n))-
time deterministic 1- tape TM.
27. PATH ∈ P.
28. REL PRIME ∈ P.
29. Every CFL is in P.
30. A language is in NP iff it is decided by some nondeterministic polynomial- time TM.
31. NP = Uk > = 0 NTIME(nk)

BASIC THEORY OF COMPUTATION Page 119


32. CLIQUE ∈ NP.
33. SUBSET-SUM ∈ NP.
34. If A < =P PB and B ∈ P, then A ∈ P.
35. 3SAT is polynomial-time reducible to CLIQUE
36. If there is an NP-Complete problem B and B ∈ P, then P = NP.
37. If B is NP- Complete and B < =P C for C ∈ NP, the n C is NP- Complete.
38. SAT is NP- Complete.
39. SAT is NP- Complete
40. CLIQUE is NP- Complete.
41. ILP is NP-Complete.

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)= *

• Some questions about the languages of CFGs are decidable


Is L(G) = , some aren’t like Is L(G) = *
• Everything we’ve tried for Turing machines is undecidable.
Is L(G) = , L(G)= * • Is the language semi decided by M regular? Context-free?
For Context free Grammar it is undecidable
 whether a CFG accepts the language of all strings
 whether two CFGs describe the same language
 whether CFG is ambiguous
 if a context-sensitive grammar describes a context-free language
 if a CFG, has an equivalent PDA that is deterministic
 if Given an ambiguous CFG, whether or not there is a different CFG that generates the
same language but is not ambiguous
 whether the complement of a given CFL is context free?
 whether the intersection of two CFL's is context free?
 given two CFG's, how can we tell if they have a word in common?
Decidable Problem for CFG
 DPDA Equality is Decidable
 Membership is decidable

BASIC THEORY OF COMPUTATION Page 120

You might also like