1. The following grammar
G = (N, T, P, S)
N = {S, A, B}
T = {a, b, c}
P : S → aSa
S → aAa
A → bB
B → bB
B → 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
2. 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
3. The following grammar
G = (N, T, P, S)
N = {S, A, B, C}
T = {a, b, c}
P : S → aS
A → bB
B → cC
C → a 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
4. 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
5. Consider the following CFG
S → aB S → bA
B → b A → a
B → bS A → aS
B → aBB A → bAA
Consider the following derivation
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
6. Consider the following language
L = {anbncndn|n ≥ 1}
L is
a. CFL but not regular
b. CSL but not CFL
c. regular
d. type 0 language but not type 1
7. Consider the following language
L = {anbn|n ≥ 1}
L is
a. CFL but not regular
b. CSL but not CFL
c. regular
d. type 0 language but not type 1
8. Consider the following language
L = {anbmcpdq|n, m, p, q ≥ 1}
L is
a. CFL but not regular
b. CSL but not CFL
c. regular
d. type 0 language but not type 1
9. The following CFG is in
S → AB
B → CD
B → AD
B → b
D → AD
D → d
A → a
C → a
a. Chomsky normal form but not strong Chomsky normal form
b. Weak Chomsky normal form but not Chomsky normal form
c. Strong Chomsky normal form
d. Greibach normal form
10. The following CFG is in
S → aBB
B → bAA
A → a
B → b
a. Chomsky normal form but not strong Chomsky normal form
b. Weak Chomsky normal form but not Chomsky normal form
c. Strong Chomsky normal form
d. Greibach normal form
11. Which of the following CF language is inherently ambiguous?
a. {anbncmdm|n, m ≥ 1}
b. {anbmcpdq|n = p or m = q, n, m, p, q ≥ 1}
c. {anbmcpdq|n ≠ m ∧ p ≠ q}
d. {anbmcpdq|n ≠ m ∨ p ≠ q}
12. Which string is not accepted by the following FSA?
a. 00111
b. 01010
c. 00110
d. 11010
13. Which string is accepted by the following FSA?
a. 00111
b. 11011
c. 01101
d. 0101
14. Can a DFSA simulate a NFSA
a. No
b. Yes
c. sometimes
d. depends on NFA
15. Which of the following is true for an arbitrary language L.
a.
b. L* = L+ ∪ {λ}
c. L* = L+
d. L* = L+ − {λ}
16. The concept of FSA is much used in this part of the compiler
a. lexical analysis
b. parser
c. code generation
d. code optimization
17. The concept of grammar is much used in this part of the compiler
a. lexical analysis
b. parser
c. code generation
d. code optimization
18. (a + b)(cd)*(a + b) denotes the following set
a. {a(cd)nb|n ≥ 1}
b. {a(cd)na|n ≥ 1} ∪ {b(cd)nb/n ≥ 1}
c. {a(cd)na|n ≥ 0} ∪ {a(cd)nb/n ≥ 0} ∪ {b(cd)na/n ≥ 0} ∪ {b(cd)nb/n ≥ 0}
d. {acndnb|n ≥ 1}
19. baa*c denotes the set
a. {bnamcp|n, m, p ≥ 1}
b. {banc|n ≥ 0}
c. {banc|n ≥ 1}
d. {w|w is a string of a, b, c}
20. The set of all strings over the alphabet Σ = {a, b} (including ε) is denoted by
a. (a + b)*
b. (a + b)+
c. a+b+
d. a*b*
21. Palindromes can’t be recognized by any FSA because
a. FSA cannot remember arbitrarily large amount of information
b. FSA cannot deterministically fix the midpoint
c. Even if the mid point is known an FSA cannot find whether the second half of the string matches the first half
d. all of the above
22. Let Σ = {a, b, c, d, e}. The number of strings in Σ* of length 4 such that no symbol is used more than once in a string is
a. 360
b. 120
c. 35d. 36
23. Which of the following denotes Chomskian hiearchy?
a. REG ⊂ CFL ⊂ CSL ⊂ type0
b. CFL ⊂ REG ⊂ type0 ⊂ CSL
c. CSL ⊂ type0 ⊂ REG ⊂ CFL
d. CSL ⊂ CFL ⊂ REG ⊂ type0
24. A language L is accepted by a FSA iff it is
a. CFL
b. CSL
c. recursive
d. regular
25. Which of the following regular expressions denotes a language comprising of all possible strings over Σ = {a, b} of length n where n is a multiple of 3.
a. (a + b + aa + bb + aba + bba)*
b. (aaa + bbb)*
c. ((a + b)(a + b)(a + b))*
d. (aaa + ab + a) + (bbb + bb + a)
26. A language is represented by a regular expression (a)*(a + ba). Which of the following string does not belong to the regular set represented by the above expression.
a. aaa
b. aba
c. ababad. aa
27. Which of the following is not primitive recursive but partially recursive?
a. McCarthy’s function
b. Riemann function
c. Ackermann’s function
d. Bounded function
28. Consider the following right-linear grammar G = (N, T, P, S) N = {S}
P : S → aS|aA T = {a, b}
A → bA|b
Which of the following regular expression denotes L(G)?
a. (a + b)*
b. a(ab)*b
c. aa*bb*
d. a*b*
29. Which of the following strings is not generated by the following grammar? S→ SaSbS|ε
a. aabb
b. abab
c. aababb
d. aaabb
30. Consider the following NFSA
The automaton accepts
a. all words of the form {(ab)na|n ≥ 1}
b. all words that end with a and ε
c. all words that end with a and not ε
d. all words containing substring ba
31. Consider a language L for which there exists a Turing machine (TM), T, that accepts every word in L and either rejects or loops for every word that is not in L. The language L is
a. NP hard
b. NP complete
c. recursive
d. recursively enumerable
32. Consider the following statements
I. Recursive languages are closed under complementation
II. Recursively enumerable languages are closed under union
III. Recursively enumerable languages are closed under complementation
Which of the above statement are TRUE?
a. I only
b. I and II
c. I and III
d. II and III
33. Which of the following statement is wrong?
a. Any regular language can be generated by a context-free grammar
b. Some non-regular languages cannot be generated by any CFG
c. the intersection of a CFL and regular set is a CFL
d. All non-regular languages can be generated by CFGs.
34. Recursively enumerable languages are not closed under
a. union
b. homomorphism
c. complementation
d. concatenation
35. 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
36. Recursive languages are
a. a proper superset of CFL
b. always recognized by PDA
c. are also called type 0 languages
d. always recognized by FSA
37. R1 and R2 are regular sets. Which of the following is not true?
a. R1 ∩ R2 neet not be regular
b. Σ* − R1 is regular
c. R1 ∪ R2 is regular
d. is regular
38. Which of the following regular expression identity is true?
a. r(*) = r*
b. (r*s*)* = (r + s)*
c. (r + s)* = r* + s*
d. r*s* = r* + s*
39. Which one of the following statement is FALSE?
a. context-free languages are closed under union
b. context-free languages are closed under concatenation
c. context-free languages are closed under intersection
d. context-free languages are closed under Kleene closure
40. Which of the following conversion is not possible (algorithmically)?
a. regular grammar to context-free grammar
b. nondeterministic FSA to deterministic FSA
c. nondeterministic PDA to deterministic PDA
d. nondeterministic TM to deterministic TM
41. Consider three decision problems P1, P2 and P3. It is known that P1 is decidable and P2 is undecidable. Which one of the following is TRUE?
a. P3 is decidable if P1 is reducible to P3
b. P3 is undecidable if P3 is reducible to P2
c. P3 is undecidable if P2 is reducible to P3
d. P3 is decidable if P3 is reducible to P2’s complement
42. Consider three problems P1, P2 and P3. It is known that P1 has polynomial time solution and P2 is NP-complete and P3 is in NP. Which one of the following is true.
a. P3 has polynomial time solution if P1 is polynomial time reducible toP3
b. P3 is NP complete if P3 is polynomial time reducible to P2
c. P3 is NP complete if P2 is reducible to P3
d. P3 has polynomial time complexity and P3 is reducible to P2
43. Consider the FSA M
The language recognized by M is
a. {w ∊ {a, b}* | every a in w is followed by exactly two b’s}
b. {w ∊ {a, b}* | every a in w is followed by atleast two b’s}
c. {w ∊ {a, b}* |w contains the substring ‘abb’}
d. {w ∊ {a, b}* |w does not contain ‘aa’ as substring}
44. Let Nf and Np denote the classes of languages accepted by nondeterministic FSA and nondeterministic PDA, respectively. Let Df and Dp denote the classes of languages accepted by deterministic FSA and PDA respectively. Which of the following is TRUE?
Some of these questions have appeared in GATE examinations.
a. Df ⊂ Nf Dp ⊂ Np
b. Df ⊂ Nf Dp = Np
c. Df = Nf Dp ⊂ Np
d. Df = Nf Dp = Np
45. Consider the languages
L1 = {anbncm|n, m > 0} and L2 = {anbmcm|n, m > 0}
Which one of the following statements is false?
a. L1 ∩ L2 is a CFL
b. L1 ∪ L2 is a CFL
c. L1 ∪ L2 is inherently ambiguous
d. L1 ∩ L2 is a CSL
46. Consider the languages
L1 = {anbmcndp|n, m, p > 0} and L2 = {anbmcpdm|n, m, p> 0}
Which one of the following statements is false?
a. L1 ∩ L2 is a CFL
b. L1 ∪ L2 is a CFL
c. L1 ∪ L2 is inherently ambiguous
d. L1 ∩ L2 is a CSL
47. Consider the languages
L1 = {anbmcmdn|n, m > 0} and L2 = {anbncmdm|n, m > 0}
Which one of the following statements is false?
a. L1 ∪ L2 is a CFL
b. L1 ∩ L2 is a CFL
c. L1 and L2 are CFL
d. L1 ∩ L2 is a CSL
48. Let L and be a language and its complement. Which one of the following possibilities will not hold?
a. L and are recursive
b. L is recursively enumerable but not recursive is not recursively enumerable
c. L and are not recursively enumerable
d. L and are recursively enumerable but not recursive
49. Let L1 be a recursive language and let L2 be a recursively enumerable language which is not recursive. Which one of the following is TRUE?
a. is recursive, is recursively enumerable.
b. is recursive, is not recursively enumerable.
c. and are recursively enumerable.
d. is recursively enumerable and is recursive.
50. Consider the languages
L1 = {wwR|w ∊ {0,1}*}
L2 = {wcwR|w ∊ {0,1}*}
L3 = {ww|w ∊ {0,1}*}
Which one of the following is TRUE?
a. L1 is deterministic CFL
b. L2 is deterministic CFL
c. L3 is a CFL but not a deterministic CFL
d. L3 is deterministic CFL
51. Let S be a NP–complete problem and Q and R be two other problems not known to be in NP. Q is polynomial time reducible to S and S is polynomial time reducible to R. Which one of the following statements is TRUE?
a. R is NP complete
b. R is NP hard
c. Q is NP complete
d. Q is NP hard
52. L1 = {an + m bn cm|n, m ≥ 0}
L2 = {an + m bn + m cm|n, m ≥ 0}
L3 = {an + m bn + m cm + n|n, m ≥ 0}
Which of these languages are not CF.
a. L1 only
b. L3 only
c. L1 and L2
d. L2 and L3
53. If s is a string over (0+1)* then let m0 (s) denote the number of 0’s in s andn1 (s) the number of 1’s in s. Which one of the following languages is not regular?
a. L = {s ∊ (0+1)*|n0(s) is a 3-digit prime}
b. L = {s ∊ (0+1)*|for every prefix s′ of s, |n0 (s′) − n1(s′)| ≤ 2}
c. L = {s ∊ (0+1)*‖n0(s) − n1(s)| ≤ 4}
d. L = {s ∊ (0+1)*|n0(s) mod 7 = n1(s) mod 5 = 0}
54. For s ∊ (0+1)*let d(s) denote the decimal value of s (eg. D(|0|) = 5).
Let L = {s ∊ (0+1)*|d(s) mod 5 = 2 and d(s) mod 7 ≠ 4}
Which one of the following statements is TRUE?
a. L is recursively enumerable but not recursive
b. L is recursive, but not context-free
c. L is context-free, but not regular
d. L is regular
55. Let FHAM be the problem of finding a Hamiltonian cycle in a graph G and DHAM be the problem of determining if a Hamiltonial cycle exists in a graph. Which one of the following is TRUE?
a. Both FHAM and DHAM are NP-hard
b. FHAM is NP hard, but DHAM is not
c. DHAM is NP hard, but FHAM is not
d. Neither FHAM nor DHAM is NP hard
56. Consider the following statements about the context-free grammar G = {S →SS, S → ab, S → ba, S → c}
I. G is ambiguous
II. G produces all strings with equal number of a’s and b’s
III. G can be accepted by a deterministic PDA
Which combination below expresses all the true statements about G?
a. I only
b. I and III only
c. II and III only
d. I, II and III
57. Let L1 be a regular language and L2 a deterministic CFL. L3 is recursively enumerable but not recursive. Which one of the following statement is FALSE?
a. L1 ∩ L2 is a DCFL
b. L3 ∩ L1 is recursive
c. L1 ∪ L2 is context-free
d. L1 ∩ L2 ∩ L3 is recursively enumerable
58. Consider the regular language L = (111 + 11111)*. The minimum number of states in any DFA accepting the language is
a. 3
b. 5
c. 8
d. 9
59. Which one of the following grammars generates the language L = {aibj|i ≠j}.
a.
S → AC|CB
C → aCb|a|b
A → aA|ε
B → Bb|ε
b.
S → aS|Sb|a|b
c.
S → AC|CB
C → aCb|ε
A → aA|ε
B → Bb|ε
d.
S → AC|CB
C → aCb|ε
A → aA|a
B → bB|b
60. In the above correct grammar what is the minimum length of the derivation (number of steps starting from S) to generate the string a1 bm with l ≠ m?
a. max(l, m) + 2
b. l + m + 2
c. l + m + 3
d. max(l, m) + 3
61. Consider S → SS|a.
What is the number of different derivation trees for aaaaa
a. 3
b. 5
c. 7
d. 14
62. Which one of the following grammar generates L = {ai bj ck|i ≠ k, i, j, k ≥ 1}
a. S → AC|CB
A → aA|a
B → Bc|c
C → aCc|bD|b
D → bD|b
b. S → aS|aA
A → bA|bB
B → cB|c
c. S → AB
A → aAb|ab
B → bBc|bc
d. S → AC|CB
A → aA|ε
B → Bc|ε
C → aCc|ε|bD
D → bD|b|ε
63. A minimum state deterministic automaton accepting the language L = {w|w ∊ {0,1}*, the number of 0’s and 1’s in w are divisible by 3 and 5 respectively} has
a. 15 states
b. 11 states
c. 10 states
d. 9 states
64. The language L = {0i21i / i ≥ 0} over the alphabet {0, 1, 2} is
a. not recursive
b. is recursive and is a deterministic CFL
c. is a regular language
d. is not a deterministic CFL but a CFL
65. Which of the following languages is regular?
a. {wwR|w ∊ {0, 1}+}
b. {wwRx|w, x ∊ {0, 1}+}
c. {w x w R|w, x ∊ {0, 1}+}
d. {xwwR|w, x ∊ {0, 1}+}
66. Let Σ = {0, 1}, L1 = Σ* and L2 = {0n 1n|n ≥ 1} then the languages L1 ∪ L2and L2 are respectively
a. regular, regular
b. regular, not regular
c. not regular, regular
d. not regular, not regular
67. Which of the following statements is false?
a. The halting problem for Turing machines is undecidable
b. determining whether a context-free grammar is ambiguous is un-decidable
c. given two arbitrary context-free grammar, G1 and G2, it is undecidable with L(G1) = L(G2)
d. given two regular grammars G1 and G2, it is undecidable whetherL(G1) = L(G2)
68. Two of the following four regular expressions are equivalent. Which two?
i. (00)* (0 + ε)
ii. (00)*
iii. 0*
iv. 0(00)*
a. (i) and (ii)
b. (ii) and (iii)
c. (i) and (iii)
d. (iii) and (iv)
69. Let L ⊆ Σ* where Σ = {a, b}. Which of the following is true?
a. L = {x|x has an equal number of a’s and b’s } is regular
b. L = {an bn | n ≥ 1} is regular
c. L = {am bn | m, n ≥ 1} is regular
d. L = {x|x has more a’s than b’s} is regular
70. Define for a CFL L, init (L) = {u | uv ∊ L for some v ∊ {0, 1}*}. In other words init (L) is the set of prefixes of L. Let L = {w|w ∊ {0, 1}+, w has equal number of 0’s and 1’s}. Then init (L) is
a. the set of all binary strings with unequal number of 0’s and 1’s
b. the set of all binary stings including ε
c. the set of all binary strings with exactly one more 0 than the number of 1’s or one more 1 than the number of 0’s.
d. none of the above
71. If L1 and L2 are CFL and R a regular set, one of the languages below is not necessarily a CFL. Which one?
a. L1L2
b. L1 ∪ L2
c. L1 ∩ L2
d. L1 ∩ R
72. The grammar whose productions are
〈stmt〉 → if 〈id〉 then 〈stmt〉
〈stmt〉 → if 〈id〉 then 〈stmt〉 else 〈stmt〉
〈stmt〉 → 〈id〉 := 〈id〉
〈id〉 → a|b|c|d|f
is ambiguous because
a. the sentence if a then if b then c := d has more than one derivation trees
b. the leftmost and rightmost derivation of the sentence if a then if bthen c := d give rise to different parse trees
c. the sentence if a then if b then c := d else c := f has more than two parse trees
d. the sentence if a then if b then c := d else c := f has two parse trees
73. Which one of the following regular expressions over {0, 1} denotes the set of all strings not containing 100 as a substring?
a. 0*(11*0)*
b. 0*1010*
c. 0*1*01
d. 0*(10 + 1)*
74. Which one of the following is not decidable?
a. given a Turing machine M, a string s, and an integer k, M acceptss with k steps
b. equivalence of two given Turing machines
c. language accepted by a given DFSA is nonempty
d. language generated by a CFG is nonempty
75. Which of the following languages over {a, b, c} is accepted by a deterministic PDA?
a. {wbwR|w ∊ {a, c}*}
b. {wwR|w ∊ {a, b, c}*}
c. {anbncn|n ≥ 1}
d. {w|w is a palindrome over {a, b, c}}
76. Which of the following instances of the post correspondence problem has a viable sequence (a solution)?
a. {(b, bb), (bb, bab), (bab, abb), (abb, babb)}
b. {(ab, aba), (baa, aa), (aba, baa)}
c. {(ab, abb), (ba, aaa), (aa, a)}
d. none of the above
77. It is undecidable, whether
a. an arbitrary TM has 15 states
b. an arbitrary TM halts after 10 steps
c. an arbitrary TM ever prints a specific letter
d. an arbitrary TM accepts a string w in 5 steps
78. Let r = 1(1+0)*, s = 11*0 and t = 1*0 be three regular expressions and R, S, T the regular sets corresponding to them. Which of the following is true?
a. S ⊂ R
b. R ⊂ S
c. T ⊂ S
d. R ⊂ T
79. Which one of the following is the strongest correct statement about a finite language L over a finite alphabet Σ?
a. L is undecidable
b. L is recursive
c. L is a CSL
d. L is a regular set
80. Which of the following statements is TRUE?
a. infinite union of regular sets is regular
b. infinite union of finite sets is regular
c. finite union of finite sets is regular
d. complement of a finite set need not be regular
G = (N, T, P, S)
N = {S, A, B}
T = {a, b, c}
P : S → aSa
S → aAa
A → bB
B → bB
B → 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
2. 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
3. The following grammar
G = (N, T, P, S)
N = {S, A, B, C}
T = {a, b, c}
P : S → aS
A → bB
B → cC
C → a 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
4. 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
5. Consider the following CFG
S → aB S → bA
B → b A → a
B → bS A → aS
B → aBB A → bAA
Consider the following derivation
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
6. Consider the following language
L = {anbncndn|n ≥ 1}
L is
a. CFL but not regular
b. CSL but not CFL
c. regular
d. type 0 language but not type 1
7. Consider the following language
L = {anbn|n ≥ 1}
L is
a. CFL but not regular
b. CSL but not CFL
c. regular
d. type 0 language but not type 1
8. Consider the following language
L = {anbmcpdq|n, m, p, q ≥ 1}
L is
a. CFL but not regular
b. CSL but not CFL
c. regular
d. type 0 language but not type 1
9. The following CFG is in
S → AB
B → CD
B → AD
B → b
D → AD
D → d
A → a
C → a
a. Chomsky normal form but not strong Chomsky normal form
b. Weak Chomsky normal form but not Chomsky normal form
c. Strong Chomsky normal form
d. Greibach normal form
10. The following CFG is in
S → aBB
B → bAA
A → a
B → b
a. Chomsky normal form but not strong Chomsky normal form
b. Weak Chomsky normal form but not Chomsky normal form
c. Strong Chomsky normal form
d. Greibach normal form
11. Which of the following CF language is inherently ambiguous?
a. {anbncmdm|n, m ≥ 1}
b. {anbmcpdq|n = p or m = q, n, m, p, q ≥ 1}
c. {anbmcpdq|n ≠ m ∧ p ≠ q}
d. {anbmcpdq|n ≠ m ∨ p ≠ q}
12. Which string is not accepted by the following FSA?
a. 00111
b. 01010
c. 00110
d. 11010
13. Which string is accepted by the following FSA?
a. 00111
b. 11011
c. 01101
d. 0101
14. Can a DFSA simulate a NFSA
a. No
b. Yes
c. sometimes
d. depends on NFA
15. Which of the following is true for an arbitrary language L.
a.
b. L* = L+ ∪ {λ}
c. L* = L+
d. L* = L+ − {λ}
16. The concept of FSA is much used in this part of the compiler
a. lexical analysis
b. parser
c. code generation
d. code optimization
17. The concept of grammar is much used in this part of the compiler
a. lexical analysis
b. parser
c. code generation
d. code optimization
18. (a + b)(cd)*(a + b) denotes the following set
a. {a(cd)nb|n ≥ 1}
b. {a(cd)na|n ≥ 1} ∪ {b(cd)nb/n ≥ 1}
c. {a(cd)na|n ≥ 0} ∪ {a(cd)nb/n ≥ 0} ∪ {b(cd)na/n ≥ 0} ∪ {b(cd)nb/n ≥ 0}
d. {acndnb|n ≥ 1}
19. baa*c denotes the set
a. {bnamcp|n, m, p ≥ 1}
b. {banc|n ≥ 0}
c. {banc|n ≥ 1}
d. {w|w is a string of a, b, c}
20. The set of all strings over the alphabet Σ = {a, b} (including ε) is denoted by
a. (a + b)*
b. (a + b)+
c. a+b+
d. a*b*
21. Palindromes can’t be recognized by any FSA because
a. FSA cannot remember arbitrarily large amount of information
b. FSA cannot deterministically fix the midpoint
c. Even if the mid point is known an FSA cannot find whether the second half of the string matches the first half
d. all of the above
22. Let Σ = {a, b, c, d, e}. The number of strings in Σ* of length 4 such that no symbol is used more than once in a string is
a. 360
b. 120
c. 35d. 36
23. Which of the following denotes Chomskian hiearchy?
a. REG ⊂ CFL ⊂ CSL ⊂ type0
b. CFL ⊂ REG ⊂ type0 ⊂ CSL
c. CSL ⊂ type0 ⊂ REG ⊂ CFL
d. CSL ⊂ CFL ⊂ REG ⊂ type0
24. A language L is accepted by a FSA iff it is
a. CFL
b. CSL
c. recursive
d. regular
25. Which of the following regular expressions denotes a language comprising of all possible strings over Σ = {a, b} of length n where n is a multiple of 3.
a. (a + b + aa + bb + aba + bba)*
b. (aaa + bbb)*
c. ((a + b)(a + b)(a + b))*
d. (aaa + ab + a) + (bbb + bb + a)
26. A language is represented by a regular expression (a)*(a + ba). Which of the following string does not belong to the regular set represented by the above expression.
a. aaa
b. aba
c. ababad. aa
27. Which of the following is not primitive recursive but partially recursive?
a. McCarthy’s function
b. Riemann function
c. Ackermann’s function
d. Bounded function
28. Consider the following right-linear grammar G = (N, T, P, S) N = {S}
P : S → aS|aA T = {a, b}
A → bA|b
Which of the following regular expression denotes L(G)?
a. (a + b)*
b. a(ab)*b
c. aa*bb*
d. a*b*
29. Which of the following strings is not generated by the following grammar? S→ SaSbS|ε
a. aabb
b. abab
c. aababb
d. aaabb
30. Consider the following NFSA
The automaton accepts
a. all words of the form {(ab)na|n ≥ 1}
b. all words that end with a and ε
c. all words that end with a and not ε
d. all words containing substring ba
31. Consider a language L for which there exists a Turing machine (TM), T, that accepts every word in L and either rejects or loops for every word that is not in L. The language L is
a. NP hard
b. NP complete
c. recursive
d. recursively enumerable
32. Consider the following statements
I. Recursive languages are closed under complementation
II. Recursively enumerable languages are closed under union
III. Recursively enumerable languages are closed under complementation
Which of the above statement are TRUE?
a. I only
b. I and II
c. I and III
d. II and III
33. Which of the following statement is wrong?
a. Any regular language can be generated by a context-free grammar
b. Some non-regular languages cannot be generated by any CFG
c. the intersection of a CFL and regular set is a CFL
d. All non-regular languages can be generated by CFGs.
34. Recursively enumerable languages are not closed under
a. union
b. homomorphism
c. complementation
d. concatenation
35. 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
36. Recursive languages are
a. a proper superset of CFL
b. always recognized by PDA
c. are also called type 0 languages
d. always recognized by FSA
37. R1 and R2 are regular sets. Which of the following is not true?
a. R1 ∩ R2 neet not be regular
b. Σ* − R1 is regular
c. R1 ∪ R2 is regular
d. is regular
38. Which of the following regular expression identity is true?
a. r(*) = r*
b. (r*s*)* = (r + s)*
c. (r + s)* = r* + s*
d. r*s* = r* + s*
39. Which one of the following statement is FALSE?
a. context-free languages are closed under union
b. context-free languages are closed under concatenation
c. context-free languages are closed under intersection
d. context-free languages are closed under Kleene closure
40. Which of the following conversion is not possible (algorithmically)?
a. regular grammar to context-free grammar
b. nondeterministic FSA to deterministic FSA
c. nondeterministic PDA to deterministic PDA
d. nondeterministic TM to deterministic TM
41. Consider three decision problems P1, P2 and P3. It is known that P1 is decidable and P2 is undecidable. Which one of the following is TRUE?
a. P3 is decidable if P1 is reducible to P3
b. P3 is undecidable if P3 is reducible to P2
c. P3 is undecidable if P2 is reducible to P3
d. P3 is decidable if P3 is reducible to P2’s complement
42. Consider three problems P1, P2 and P3. It is known that P1 has polynomial time solution and P2 is NP-complete and P3 is in NP. Which one of the following is true.
a. P3 has polynomial time solution if P1 is polynomial time reducible toP3
b. P3 is NP complete if P3 is polynomial time reducible to P2
c. P3 is NP complete if P2 is reducible to P3
d. P3 has polynomial time complexity and P3 is reducible to P2
43. Consider the FSA M
The language recognized by M is
a. {w ∊ {a, b}* | every a in w is followed by exactly two b’s}
b. {w ∊ {a, b}* | every a in w is followed by atleast two b’s}
c. {w ∊ {a, b}* |w contains the substring ‘abb’}
d. {w ∊ {a, b}* |w does not contain ‘aa’ as substring}
44. Let Nf and Np denote the classes of languages accepted by nondeterministic FSA and nondeterministic PDA, respectively. Let Df and Dp denote the classes of languages accepted by deterministic FSA and PDA respectively. Which of the following is TRUE?
Some of these questions have appeared in GATE examinations.
a. Df ⊂ Nf Dp ⊂ Np
b. Df ⊂ Nf Dp = Np
c. Df = Nf Dp ⊂ Np
d. Df = Nf Dp = Np
45. Consider the languages
L1 = {anbncm|n, m > 0} and L2 = {anbmcm|n, m > 0}
Which one of the following statements is false?
a. L1 ∩ L2 is a CFL
b. L1 ∪ L2 is a CFL
c. L1 ∪ L2 is inherently ambiguous
d. L1 ∩ L2 is a CSL
46. Consider the languages
L1 = {anbmcndp|n, m, p > 0} and L2 = {anbmcpdm|n, m, p> 0}
Which one of the following statements is false?
a. L1 ∩ L2 is a CFL
b. L1 ∪ L2 is a CFL
c. L1 ∪ L2 is inherently ambiguous
d. L1 ∩ L2 is a CSL
47. Consider the languages
L1 = {anbmcmdn|n, m > 0} and L2 = {anbncmdm|n, m > 0}
Which one of the following statements is false?
a. L1 ∪ L2 is a CFL
b. L1 ∩ L2 is a CFL
c. L1 and L2 are CFL
d. L1 ∩ L2 is a CSL
48. Let L and be a language and its complement. Which one of the following possibilities will not hold?
a. L and are recursive
b. L is recursively enumerable but not recursive is not recursively enumerable
c. L and are not recursively enumerable
d. L and are recursively enumerable but not recursive
49. Let L1 be a recursive language and let L2 be a recursively enumerable language which is not recursive. Which one of the following is TRUE?
a. is recursive, is recursively enumerable.
b. is recursive, is not recursively enumerable.
c. and are recursively enumerable.
d. is recursively enumerable and is recursive.
50. Consider the languages
L1 = {wwR|w ∊ {0,1}*}
L2 = {wcwR|w ∊ {0,1}*}
L3 = {ww|w ∊ {0,1}*}
Which one of the following is TRUE?
a. L1 is deterministic CFL
b. L2 is deterministic CFL
c. L3 is a CFL but not a deterministic CFL
d. L3 is deterministic CFL
51. Let S be a NP–complete problem and Q and R be two other problems not known to be in NP. Q is polynomial time reducible to S and S is polynomial time reducible to R. Which one of the following statements is TRUE?
a. R is NP complete
b. R is NP hard
c. Q is NP complete
d. Q is NP hard
52. L1 = {an + m bn cm|n, m ≥ 0}
L2 = {an + m bn + m cm|n, m ≥ 0}
L3 = {an + m bn + m cm + n|n, m ≥ 0}
Which of these languages are not CF.
a. L1 only
b. L3 only
c. L1 and L2
d. L2 and L3
53. If s is a string over (0+1)* then let m0 (s) denote the number of 0’s in s andn1 (s) the number of 1’s in s. Which one of the following languages is not regular?
a. L = {s ∊ (0+1)*|n0(s) is a 3-digit prime}
b. L = {s ∊ (0+1)*|for every prefix s′ of s, |n0 (s′) − n1(s′)| ≤ 2}
c. L = {s ∊ (0+1)*‖n0(s) − n1(s)| ≤ 4}
d. L = {s ∊ (0+1)*|n0(s) mod 7 = n1(s) mod 5 = 0}
54. For s ∊ (0+1)*let d(s) denote the decimal value of s (eg. D(|0|) = 5).
Let L = {s ∊ (0+1)*|d(s) mod 5 = 2 and d(s) mod 7 ≠ 4}
Which one of the following statements is TRUE?
a. L is recursively enumerable but not recursive
b. L is recursive, but not context-free
c. L is context-free, but not regular
d. L is regular
55. Let FHAM be the problem of finding a Hamiltonian cycle in a graph G and DHAM be the problem of determining if a Hamiltonial cycle exists in a graph. Which one of the following is TRUE?
a. Both FHAM and DHAM are NP-hard
b. FHAM is NP hard, but DHAM is not
c. DHAM is NP hard, but FHAM is not
d. Neither FHAM nor DHAM is NP hard
56. Consider the following statements about the context-free grammar G = {S →SS, S → ab, S → ba, S → c}
I. G is ambiguous
II. G produces all strings with equal number of a’s and b’s
III. G can be accepted by a deterministic PDA
Which combination below expresses all the true statements about G?
a. I only
b. I and III only
c. II and III only
d. I, II and III
57. Let L1 be a regular language and L2 a deterministic CFL. L3 is recursively enumerable but not recursive. Which one of the following statement is FALSE?
a. L1 ∩ L2 is a DCFL
b. L3 ∩ L1 is recursive
c. L1 ∪ L2 is context-free
d. L1 ∩ L2 ∩ L3 is recursively enumerable
58. Consider the regular language L = (111 + 11111)*. The minimum number of states in any DFA accepting the language is
a. 3
b. 5
c. 8
d. 9
59. Which one of the following grammars generates the language L = {aibj|i ≠j}.
a.
S → AC|CB
C → aCb|a|b
A → aA|ε
B → Bb|ε
b.
S → aS|Sb|a|b
c.
S → AC|CB
C → aCb|ε
A → aA|ε
B → Bb|ε
d.
S → AC|CB
C → aCb|ε
A → aA|a
B → bB|b
60. In the above correct grammar what is the minimum length of the derivation (number of steps starting from S) to generate the string a1 bm with l ≠ m?
a. max(l, m) + 2
b. l + m + 2
c. l + m + 3
d. max(l, m) + 3
61. Consider S → SS|a.
What is the number of different derivation trees for aaaaa
a. 3
b. 5
c. 7
d. 14
62. Which one of the following grammar generates L = {ai bj ck|i ≠ k, i, j, k ≥ 1}
a. S → AC|CB
A → aA|a
B → Bc|c
C → aCc|bD|b
D → bD|b
b. S → aS|aA
A → bA|bB
B → cB|c
c. S → AB
A → aAb|ab
B → bBc|bc
d. S → AC|CB
A → aA|ε
B → Bc|ε
C → aCc|ε|bD
D → bD|b|ε
63. A minimum state deterministic automaton accepting the language L = {w|w ∊ {0,1}*, the number of 0’s and 1’s in w are divisible by 3 and 5 respectively} has
a. 15 states
b. 11 states
c. 10 states
d. 9 states
64. The language L = {0i21i / i ≥ 0} over the alphabet {0, 1, 2} is
a. not recursive
b. is recursive and is a deterministic CFL
c. is a regular language
d. is not a deterministic CFL but a CFL
65. Which of the following languages is regular?
a. {wwR|w ∊ {0, 1}+}
b. {wwRx|w, x ∊ {0, 1}+}
c. {w x w R|w, x ∊ {0, 1}+}
d. {xwwR|w, x ∊ {0, 1}+}
66. Let Σ = {0, 1}, L1 = Σ* and L2 = {0n 1n|n ≥ 1} then the languages L1 ∪ L2and L2 are respectively
a. regular, regular
b. regular, not regular
c. not regular, regular
d. not regular, not regular
67. Which of the following statements is false?
a. The halting problem for Turing machines is undecidable
b. determining whether a context-free grammar is ambiguous is un-decidable
c. given two arbitrary context-free grammar, G1 and G2, it is undecidable with L(G1) = L(G2)
d. given two regular grammars G1 and G2, it is undecidable whetherL(G1) = L(G2)
68. Two of the following four regular expressions are equivalent. Which two?
i. (00)* (0 + ε)
ii. (00)*
iii. 0*
iv. 0(00)*
a. (i) and (ii)
b. (ii) and (iii)
c. (i) and (iii)
d. (iii) and (iv)
69. Let L ⊆ Σ* where Σ = {a, b}. Which of the following is true?
a. L = {x|x has an equal number of a’s and b’s } is regular
b. L = {an bn | n ≥ 1} is regular
c. L = {am bn | m, n ≥ 1} is regular
d. L = {x|x has more a’s than b’s} is regular
70. Define for a CFL L, init (L) = {u | uv ∊ L for some v ∊ {0, 1}*}. In other words init (L) is the set of prefixes of L. Let L = {w|w ∊ {0, 1}+, w has equal number of 0’s and 1’s}. Then init (L) is
a. the set of all binary strings with unequal number of 0’s and 1’s
b. the set of all binary stings including ε
c. the set of all binary strings with exactly one more 0 than the number of 1’s or one more 1 than the number of 0’s.
d. none of the above
71. If L1 and L2 are CFL and R a regular set, one of the languages below is not necessarily a CFL. Which one?
a. L1L2
b. L1 ∪ L2
c. L1 ∩ L2
d. L1 ∩ R
72. The grammar whose productions are
〈stmt〉 → if 〈id〉 then 〈stmt〉
〈stmt〉 → if 〈id〉 then 〈stmt〉 else 〈stmt〉
〈stmt〉 → 〈id〉 := 〈id〉
〈id〉 → a|b|c|d|f
is ambiguous because
a. the sentence if a then if b then c := d has more than one derivation trees
b. the leftmost and rightmost derivation of the sentence if a then if bthen c := d give rise to different parse trees
c. the sentence if a then if b then c := d else c := f has more than two parse trees
d. the sentence if a then if b then c := d else c := f has two parse trees
73. Which one of the following regular expressions over {0, 1} denotes the set of all strings not containing 100 as a substring?
a. 0*(11*0)*
b. 0*1010*
c. 0*1*01
d. 0*(10 + 1)*
74. Which one of the following is not decidable?
a. given a Turing machine M, a string s, and an integer k, M acceptss with k steps
b. equivalence of two given Turing machines
c. language accepted by a given DFSA is nonempty
d. language generated by a CFG is nonempty
75. Which of the following languages over {a, b, c} is accepted by a deterministic PDA?
a. {wbwR|w ∊ {a, c}*}
b. {wwR|w ∊ {a, b, c}*}
c. {anbncn|n ≥ 1}
d. {w|w is a palindrome over {a, b, c}}
76. Which of the following instances of the post correspondence problem has a viable sequence (a solution)?
a. {(b, bb), (bb, bab), (bab, abb), (abb, babb)}
b. {(ab, aba), (baa, aa), (aba, baa)}
c. {(ab, abb), (ba, aaa), (aa, a)}
d. none of the above
77. It is undecidable, whether
a. an arbitrary TM has 15 states
b. an arbitrary TM halts after 10 steps
c. an arbitrary TM ever prints a specific letter
d. an arbitrary TM accepts a string w in 5 steps
78. Let r = 1(1+0)*, s = 11*0 and t = 1*0 be three regular expressions and R, S, T the regular sets corresponding to them. Which of the following is true?
a. S ⊂ R
b. R ⊂ S
c. T ⊂ S
d. R ⊂ T
79. Which one of the following is the strongest correct statement about a finite language L over a finite alphabet Σ?
a. L is undecidable
b. L is recursive
c. L is a CSL
d. L is a regular set
80. Which of the following statements is TRUE?
a. infinite union of regular sets is regular
b. infinite union of finite sets is regular
c. finite union of finite sets is regular
d. complement of a finite set need not be regular