Flat It Gate 2
Flat It Gate 2
Flat It Gate 2
Consider a DFA over ={a,b}accepting all strings which have number of as divisible by 6 and number of bs divisible by 8. What is the minimum number of states that the DFA will have? (1) 8 (2) 14 (3) 15 (4) 48 Solution: 3 2. Consider the following languages: Li ={wwwE {a,b}*} L2 = {wwR w {a, b}*, wR is the reverse of w} L3 = {021 i is an integer) L4= {o2 i is an integer) Which of the languages are regular? (1) Only Li and L2 (2) Only L2, L3 and L4 (3) Only L3 and L4 (4) Only L3 [Gate-2001]
[Gate-2001]
Given a Turing machine M over the input alphabet , any state q of M And a word w E*, does the computation of M on w visit the state q? Which of the following statements about X is correct? (1) X is decidable (2) X is undecidable but partially decidable
IT DEPARTMENT GATE MATERIAL
(3) X is undecidable and not even partially decidable (4) X is not a decision problem
[Gate-2001]
5. If the strings of a language L can be effectively enumerated in lexicographic (i.e., alphabetic) order, which of the following statements is true ? 1) L is necessarily finite 2) L is regular but not necessarily finite 3) L is context free but not necessarily regular 4) L is recursive but not necessarily context free
Solution: 1
[Gate-2003]
1) Removing left recursion alone 2) Factoring the grammar alone 3) Removing left recursion and factoring the grammar 4) None of these
IT DEPARTMENT GATE MATERIAL
Solution: 3
[Gate-2003]
Let S denote the set of seven bit binary strings in which the first, the fourth, and the last bits are 1. The number of strings in S that are accepted by M is 1) 1 2) 5 3) 7 4) 8
Solution:1
[Gate-2003]
8.Define languages L0 and L1 as follows : L0 = {< M, w, 0 > | M halts on w} L1 = {< M, w, 1 > | M does not halts on w} Here < M, w, i > is a triplet, whose first component. M is an encoding of a Turing Machine, second component, w, is a string, and third component, i, is a bit. Let L = L0 L1. Which of the following is true ?
1) L is recursively enumerable, but is not 2) is recursively enumerable, but L is not are recursive
GATE MATERIAL
3) Both L and
IT DEPARTMENT
Let the language accepted by M be L. Let L1 be the language accepted by the NFA M1 , obtained by changing the accepting state of M to a non-accepting state and by changing the non-accepting state of M to accepting states. Which of the following statements is true?
4) L1 = L Solution:3
IT DEPARTMENT
[Gate-2003]
GATE MATERIAL
10. The following finite state machine accepts all those binary strings in which the number of l's and 0's are respectively
1) divisible by 3 and 2 2) odd and even 3) even and odd 4) divisible by 2 and 3 Solution:1 11. The language {am bn Cm + n | m, n 1} is [Gate-2004]
1) regular 2) context-free but not regular 3) context sensitive but not context free 4) type-0 but not context sensitive Solution:2 12. Consider the following grammar G: S bS | aA | b A bA | aB B bB | aS | a [Gate-2004]
IT DEPARTMENT
GATE MATERIAL
Let Na (w) and Nb (w) denote the number of a's and b's in a string w respectively. The language L(G) 1) { w | Na(w) > 3Nb(w)} 2) { w | Nb (w) > 3Nb (w)} 3) { w | Na(w) = 3k, k 4) { w | Nb (w) = 3k, k Solution:3 {0, 1, 2, ...}} {0, 1, 2, ...}} [Gate-2004] {a, b}+ generated by G is
13. L1 is a recursively enumerable language over . An algorithm A effectively enumerates its words as w1, w2, w3 , ... Define another language L2 over Union {#} as {w i # wj : wi , wj L1, i < j}. Here # is a new symbol. Consider the following assertions. S1 : L1 is recursive implies L2 is recursive S2 : L2 is recursive implies L1 is recursive Which of the following statements is true ? 1) Both S1 and S2 are true 2) S1 is true but S2 is not necessarily true 3) S2 is true but S1 is not necessarily true 4) Neither is necessarily true
[Gate-2004]
IT DEPARTMENT
GATE MATERIAL
1) {w {a, b}* / every a in w is followed by exactly two b's} 2) {w {a, b}* every a in w is followed by at least two b} 3) {w {a, b}* w contains the substring 'abb'} 4) {w {a, b}* w does not contain 'aa' as a substring} Solution:2 [Gate-2005]
15. Let Nf and Np denote the classes of languages accepted by nondeterministic finite automata and non-deterministic push-down automata,
respectively. Let Df and Dp denote the classes of languages accepted by deterministic finite automata and deterministic push- down automata, respectively. Which one of the following is TRUE? 1) Df 2) Df Nf and Dp Np
Nf and Dp = Np
3) Df = Nf and Dp = Np 4) Df = Nf and Dp Np
[Gate-2005]
GATE MATERIAL
L1 = {an bn cm | n, m > 0} and L2 = {an b mcm | n, m > 0} Which one of the following statements is FALSE? 1) L1 L2 is a context-free language 2) L1 L2 is a context-free language
Solution: 1 17. Consider the languages L1 = {wwR |w L2 = {w # wR | w L3 = {ww | w {0, 1}*} {0, 1}*}, where # is a special symbol (0, 1}*)
[Gate-2005]
1) L1 is a deterministic CFL 2) L2 is a deterministic CFL 3) L3 is a CFL, but not a deterministic CFL 4) L3 is a deterministic CFL
Solution: 2
[Gate-2005]
18. The following diagram represents a finite state machine which takes as input a binary number from the least significant bit.
IT DEPARTMENT
GATE MATERIAL
1) It computes 1's complement of the input number 2) It computes 2's complement of the input number 3) It increments the input number 4) It decrements the input number
Solution: 2
[Gate-2005]
19. If s is a string over (0 + 1)*, then let n0 (s) denote the number of 0's in s and n1(s) the number of 1's in s. Which one of the following languages is not regular ?
1) L = {s 2) L = {s 3) L = {s 4) L = {s
(0 + 1)* | n0 (s) is a 3-digit prime} (0 + 1)* | for every prefix s' of s, | n0 (s') - n1 (s') | 2} (0 + 1)* | n0 (s) - n1(s) 4} (0 + 1)* | n0 (s) mod 7 = n1 (s) mod 5 = 0}
[Gate-2006] (0 + 1) * let d(s) denote the decimal value of s (e.g. d (101) = 5). (0 + 1)* | d (s) mod 5 = 2 and d (s) mod 7 4) Which one of the following
statements is true ?
Solution:2 21. Consider the following statements about the contextfree grammar, G = (S SS, S ab, S ba, S ) I. G is ambiguous
[Gate-2006]
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?
1) I only 2) I and III only 3) II and III only 4) I, II, and III Solution:4 22. Let L1 be regular language, L2 [Gate-2006] be a deterministic context-free
language and L3 a recursively enumerable, but not recursive, language. Which one of the following statements is false ? 1) L1 L2 is a deterministic CFL 2) L3 L1 is recursive 3) L1 L2 is context free 4) L1 L2 L3 is recursively enumerable Solution:4
IT DEPARTMENT
[Gate-2006]
GATE MATERIAL
23. Consider the regular language L = (111 + 11111)*. The minimum number of states in any DFA accepting this languages is
1) 3 Solution:4
2) 5
3) 8
4) 9 [Gate-2006]
1) Membership problem for CFGs. 2) Ambiguity problem for CFGs. 3) Finiteness problem for FSAs. 4) Equivalence problem for FSAs.
[Gate-2007]
1) Every subset of a regular set is regular 2) Every finite subset of a non-regular set is regular 3) The union of two non-regular sets is not regular 4) Infinite union of finite sets is regular
Solution:2
[Gate-2007]
26. A minimum state deterministic finite automaton accepting the language L = {w | w has
IT DEPARTMENT GATE MATERIAL
1) not recursive 2) is recursive and is a deterministic CFL 3) is a regular language 4) is not a deterministic CFL but a CFL
[Gate-2007]
1) {wwR | w {0, 1}+} 2) {wwR x | x, w {0, 1}+} 3) {wxwR | x, w {0, 1}+} 4) {xwwR | x, w {0, 1}+}
Solution:3
[Gate-2007]
29. Consider the grammar with non-terminals N = {S, C, S1), terminals T = {a, b, i, t, e}, with S as the start symbol, and the following set of rules
IT DEPARTMENT GATE MATERIAL
30. Consider the following two statements : P : Every regular grammar is LL (1) Q : Every regular set has a LR (1) grammar Which of the
following is TRUE ?
1) Both P and Q are true. 2) P is true and Q is false. 3) P is false and Q is true. 4) Both P and Q are false.
Solution:2
[Gate-2007]
IT DEPARTMENT
GATE MATERIAL
31. The language accepted by this automaton is given by the regular expression
1) b * ab * ab * ab * 2) (a + b) * 3) b * a (a + b) * 4) b * ab * ab *
Solution:3
[Gate-2007]
32. The minimum state automaton equivalent to the above FSA has the following number of states 1) 1 2) 2 3) 3 4) 4
Solution:2 33. Which of the following is true for the language {ap | p is a prime} ?
[Gate-2007]
1) It is not accepted by a Turing Machine 2) It is regular but not context-free 3) It is context-free but not regular 4) It is neither regular nor context-free, but accepted by a Turing machine
IT DEPARTMENT GATE MATERIAL
[Gate-2008]
I. Whether the intersection of two regular languages is infinite II. Whether a given context-free language is regular III. Whether two push-down automata accept the same language IV. Whether a given grammar is context-free
1) I and II 2) I and IV 3) II and III 4) II and IV Solution:2 35. If L and are recursively enumerable then L is [Gate-2008]
1) regular 2) context-free 3) context-sensitive 4) recursive Solution:4 36. Which of the following statements is false? 1) Every NFA can be converted to an equivalent DFA 2) Every non-deterministic Turing machine can be converted to an equivalent deterministic Turing machine 3) Every regular language is also a context-free language 4) Every subset of a recursively enumerable set is recursive [Gate-2008]
IT DEPARTMENT
GATE MATERIAL
Solution:4 [Gate-2008] 37. Which of the following statements are true? I. Every left-recursive grammar can be converted to a right-recursive grammar and All -productions
suitable transformations III. The language generated by a context-free grammar all of whose productions are of the form X w or X wY (where, w is a string of terminals and Y is a non-terminal), is always regular IV. The derivation trees of strings generated by a context-free grammar in Chomsky Normal Form are always binary trees 1) I, II, III and IV 2) II, III and IV only 3) I, III and IV only 4) I, II and IV only Solution:4 38. . Match the following Checking that identifiers are (E) declared before their use Number of formal parameters in the declaration of a function agrees (F) with the number of actual parameters (Q) X X b X | X c X | d X f | g in a use of that function
IT DEPARTMENT GATE MATERIAL
[Gate-2008]
1) E P, F R, G Q, H S 2) E R, F P, G S, H Q 3) E R, F P, G Q, H S 4) E P, F R, G S, H Q Solution:3 [Gate-2008]
39. Match the following NFAs with the regular expressions they correspond to.
1) P 2, Q 1, R 3, S 4 2) P 1, Q 3, R 2, S 4 3) P 1, Q 2, R 3, S 4 4) P 3, Q 2, R 1, S 4
Solution:3 40. Which of the following are regular sets? I. {an b2m | n 0, m 0}
[Gate-2008]
41. S aSa | bSb | a | b; The language generated by the above grammar over the alphabet {a, b} is the set of
1) All palindromes. 2) All odd length palindromes. 3) Strings that begin and end with the same symbol.
IT DEPARTMENT GATE MATERIAL
Solution:2
[Gate-2009]
42. Which one of the following languages over the alphabet {0, 1} is described by the regular expression: (0 + 1)* 0(0 + 1)* 0(0 + 1)*?
1) The set of all strings containing the substring 00. 2) The set of all strings containing at most two 0s. 3) The set of all strings containing at least two 0s. 4) The set of all strings that begin and end with either 0 or 1.
[Gate-2009]
1) There is unique minimal DFA for every regular language. 2) Every NFA can be converted to an equivalent PDA. 3) Complement of every context-free language is recursive. 4) Every nondeterministic PDA can be converted to an equivalent deterministic PDA.
Solution:4
[Gate-2009]
IT DEPARTMENT
GATE MATERIAL
1) Not recursive 2) Regular 3) Context free but not regular 4) Recursively enumerable but not context free Solution:3 [Gate-2009]
45. The above DFA accepts the set of all strings over {0, 1} that
1) begin either with 0 or 1 2) end with 0 3) end with 00 4) contain the substring 00
bit strings with even number of 1s. Which one of the regular expressions below represents L ?
IT DEPARTMENT GATE MATERIAL
[Gate-2010]
L1 = {0i1j | i j}. L2 = {0i1 j | i = j}. L3 = {0i1j | i = 2j + 1}. L4 = {0i1j | i 2j}. Which one of the following statements is true ?
1) Only L2 is context free 2) Only L2 and L3 are context free 3) Only L1 and L2 are context free 4) All are context free
Solution:1
[Gate-2010]
48. Let be any string of length n in {0, 1}*. Let L be the set of all substrings of. What is the minimum number of states in a non-deterministic finite automaton that accepts L ?
1) n - 1 2) n 3) n + 1 4) 2n - 1
IT DEPARTMENT GATE MATERIAL
Solution:3
[Gate-2010]
49. What is the complement of the language accepted by the NFA show below? Assume = {a} and is the empty string.
(1)
(2) {}
(3) a G
(4) {a, }
Solution:2
[Gate-2011]
50.
[Gate-2012]
GATE MATERIAL
P : S aSa S aAa A bB B bB B c is a. b. c. d. is type 3 is type 2 but not type 3 is type 1 but not type 2 is type 0 but not type 1
a. b. c. d.
is type 3 is type 2 but not type 3 is type 1 but not type 2 is type 0 but not type 1
IT DEPARTMENT
GATE MATERIAL
T = {a, b, c} P : S aS A bB B cC C a is a. b. c. d. is type 3 is type 2 but not type 3 is type 1 but not type 2 is type 0 but not type 1
a. b. c. d.
is type 3 is type 2 but not type 3 is type 1 but not type 2 is type 0 but not type 1
IT DEPARTMENT
S aB
S bA
B aBB A bAA
This derivation is a. b. c. d. a leftmost derivation a rightmost derivation both leftmost and rightmost derivation neither leftmost nor rightmost derivation
56. Consider the following language L = {anbncndn|n 1} L is a. b. c. d. CFL but not regular CSL but not CFL regular type 0 language but not type 1
57. Consider the following language L = {anbn|n 1} L is a. CFL but not regular
IT DEPARTMENT GATE MATERIAL
b. CSL but not CFL c. regular d. type 0 language but not type 1 58. Consider the following language L = {anbmcpdq|n, m, p, q 1} L is a. b. c. d. CFL but not regular CSL but not CFL regular type 0 language but not type 1
59. The following CFG is in S AB B CD B AD Bb D AD Dd Aa Ca a. b. c. d. Chomsky normal form but not strong Chomsky normal form Weak Chomsky normal form but not Chomsky normal form Strong Chomsky normal form Greibach normal form
Aa Bb a. b. c. d. Chomsky normal form but not strong Chomsky normal form Weak Chomsky normal form but not Chomsky normal form Strong Chomsky normal form Greibach normal form
61. Which of the following CF language is inherently ambiguous? a. b. c. d. {anbncmdm|n, m 1} {anbmcpdq|n = p or m = q, n, m, p, q 1} {anbmcpdq|n m p q} {anbmcpdq|n m p q}
a. b. c. d.
IT DEPARTMENT
GATE MATERIAL
a. b. c. d.
a. b. L* = L+ {} c. L* = L+ d. L* = L+ {} 66. The concept of FSA is much used in this part of the compiler a. b. c. d. lexical analysis parser code generation code optimization
67. The concept of grammar is much used in this part of the compiler a. b. c. d. lexical analysis parser code generation code optimization
68. (a + b)(cd)*(a + b) denotes the following set a. b. c. d. {a(cd)nb|n 1} {a(cd)na|n 1} {b(cd)nb/n 1} {a(cd)na|n 0} {a(cd)nb/n 0} {b(cd)na/n 0} {b(cd)nb/n 0} {acndnb|n 1}
a. {bnamcp|n, m, p 1} b. {banc|n 0} c. {banc|n 1} 70. The set of all strings over the alphabet = {a, b} (including ) is denoted by a. b. c. d. (a + b)* (a + b)+ a+b+ a*b*
71. Palindromes cant 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 72. 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. b. c. d. 360 120 35 36
73. Which of the following denotes Chomskian hiearchy? a. b. c. d. REG CFL CSL type0 CFL REG type0 CSL CSL type0 REG CFL CSL CFL REG type0
75. 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.
IT DEPARTMENT GATE MATERIAL
a. b. c. d.
(a + b + aa + bb + aba + bba)* (aaa + bbb)* ((a + b)(a + b)(a + b))* (aaa + ab + a) + (bbb + bb + a)
76. 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. b. c. d. aaa aba ababa aa
77. Which of the following is not primitive recursive but partially recursive? a. b. c. d. McCarthys function Riemann function Ackermanns function Bounded function
78. 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. b. c. d. (a + b)* a(ab)*b aa*bb* a*b*
79. Which of the following strings is not generated by the following grammar? S SaSbS| a. b. c. d. aabb abab aababb aaabb
IT DEPARTMENT
GATE MATERIAL
The automaton accepts a. b. c. d. all words of the form {(ab)na|n 1} all words that end with a and all words that end with a and not all words containing substring ba
81. 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. b. c. d. NP hard NP complete recursive recursively enumerable
82.Consider the following statements I. II. III. Recursive languages are closed under complementation Recursively enumerable languages are closed under union Recursively enumerable languages are closed under complementation
Which of the above statement are TRUE? a. b. c. d. I only I and II I and III II and III
83.Which of the following statement is wrong? a. b. c. d. Any regular language can be generated by a context-free grammar Some non-regular languages cannot be generated by any CFG the intersection of a CFL and regular set is a CFL All non-regular languages can be generated by CFGs.
c. complementation d. concatenation 85.Which of the following problem is undecidable? a. b. c. d. membership problem for CFL membership problem for regular sets membership problem for CSL membership problem for type 0 languages
86. Recursive languages are a. b. c. d. a proper superset of CFL always recognized by PDA are also called type 0 languages always recognized by FSA
87. 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
88. Which of the following regular expression identity is true? a. b. c. d. r(*) = r* (r*s*)* = (r + s)* (r + s)* = r* + s* r*s* = r* + s*
89. Which one of the following statement is FALSE? a. b. c. d. context-free languages are closed under union context-free languages are closed under concatenation context-free languages are closed under intersection context-free languages are closed under Kleene closure
90. 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
IT DEPARTMENT GATE MATERIAL
d. nondeterministic TM to deterministic TM
IT DEPARTMENT
GATE MATERIAL