Flat questions
Flat questions
9)A considered the sets of Turing machines describing all the Hamiltornian
cycle problems. Choose the correct statement.
(a) The membership problem of S is decidable
(b) It is decidable if the complement of S is empty
(c) It is decidable if S is empty, finite or infinite
(d) It is decidable if S = Σ*
Ans : (c)
Sol: By Rice’s Theorem all non-trivial properties of R.E. sets are undecidable.
The (c) is a trivial property as there are an infinite number of graphs which
have the Hamiltonian cycle.
(A) Φ
(B) ε
(C) a
(D) {a, ε}
Answer (B)
The given alphabet ∑ contains only one symbol {a} and the given
NFA accepts all strings with any number of occurrences of ‘a’. In
other words, the NFA accepts a+. Therefore complement of the
language accepted by automata is empty string.
2) The lexical analysis for a modern language such as Java
needs the power of which one of the following machine
models in a necessary and sufficient sense?
(A) Finite state automata
(B) Deterministic pushdown automata
(C) Non-deterministic pushdown automata
(D) Turing machine
Answer (A)
Lexical analysis is the first step in compilation. In lexical analysis,
program is divided into tokens. Lexical analyzers are typically
based on finite state automata. Tokens can typically be expressed
as different regular expressions:
An identifier is given by [a-zA-Z][a-zA-Z0-9]*
The keyword if is given by if.
Integers are given by [+-]?[0-9]+.
3)Definition of a language L with alphabet {a} is given as
following. L= { ank | k > 0, and n is a positive integer
constant} What is the minimum number of states needed in
a DFA to recognize L?
(A) k+1
(B) n+1
(C) 2n+1
(D) 2k+1
Answer (B)
Note that n is a constant and k is any positive integer. For example,
if n is given as 3, then the DFA must be able to accept 3a, 6a, 9a,
12a, .. To build such a DFA, we need 4 states.
4) Which one of the following is FALSE?
(A) There is unique minimal DFA for every regular language
(B) Every NFA can be converted to an equivalent PDA.
(C) Complement of every context-free language is recursive.
(D) Every nondeterministic PDA can be converted to an equivalent
deterministic PDA.
Answer (D)
Deterministic PDA cannot handle languages or grammars with
ambiguity, but NDPDA can handle languages with ambiguity and
any context-free grammar. So every nondeterministic PDA can not
be converted to an equivalent deterministic PDA.
5) . Let L = L1 ∩ L2, where L1 and L2 are languages as
defined below:
L1 = {ambmcanbn | m, n >= 0 }
L2 = {aibjck | i, j, k >= 0 }
Then L is
(A) Not recursive
(B) Regular
(C) Context free but not regular
(D) Recursively enumerable but not context free.
Answer (C)
The language L1 accept strings {c, abc, abcab, aabbcab,
aabbcaabb, …} and L2 accept strings {a, b, c, ab, abc, aabc,
aabbc, … }. Intersection of these two languages is L1 ∩L2 = {akbkc |
k >= 0} which is context free, but not regular.6) Let w be any
string of length n is {0,1}*. Let L be the set of all
substrings of w. What is the minimum number of states in a
non-deterministic finite automaton that accepts L?
(A) n-1
(B) n
(C) n+1
(D) 2n-1
Answer (C)
We need minimum n+1 states to build NFA that accepts all
substrings of a binary string. For example, following NFA accepts all
substrings of “010” and it has 4 states.
7) In the finite automaton with minimum state deterministic that accepts
a given language L={w | w ε {0,1} *, the total number of 0s as well as 1s
in w that would be divisible by 3 & 5, respectively} would have:
a. 9 states
b. 10 states
c. 11 states
d. 15 states
(m + n + o) *
a. (m*n* + o*)*
b. ((mn)* + o*)*
c. (m*n*o*)*
d. (m* + n* + o*)*
a. Recursive
d. Context Free
a. Regular language
Ans:https://gateoverflow.in/399282/gate-cse-2023-question-29
2.
Ans:https://gateoverflow.in/8357/gate-cse-2015-set-1-question-51
3.
Ans:https://gateoverflow.in/3491/gate-it-2007-question-49
4.
Ans:According to the Pumping Lemma for Regular Languages, every string w present in the infinite
regular language L should be divide into three parts w = xyz, where
(i) y
when x = b10+12k
So pumping length should must be more than 10 so that we can divide any string into three parts.
5.
Ans:https://gateoverflow.in/399282/gate-cse-2023-question-29#a_list_title
6.
Ans:https://gateoverflow.in/399308/gate-cse-2023-question-4#a_list_title
8.
10.
Ans:
1) Let L={w ∈ (0 + 1)*|w has even number of 1s}, i.e. L is the set of all bit strings with even
number of 1s. Which one of the regular expression below represents L?
(A) (0*10*1)*
(B) 0*(10*10*)*
(C) 0*(10*1*)*0*
(D) 0*1(10*1)*10*
Answer (B)
Option (A) is incorrect because it cannot accept “110”
Option (C) is incorrect because it accept a string with single 1.
Option (D) is incorrect because it cannot accept 11101
Answer (D)
A Pushdown Automata can be built for all four languages.
3) Let w be any string of length n is {0,1}*. Let L be the set of all substrings of w. What is
the minimum number of states in a non-deterministic finite automaton that accepts L?
(A) n-1
(B) n
(C) n+1
(D) 2n-1
Answer (C)
We need minimum n+1 states to build NFA that accepts all substrings of a binary string. For
example, following NFA accepts all substrings of “010” and it has 4 states.
4) What is the complement of the language accepted by the NFA shown below? Assume ∑ =
{a} and ε is the empty string
(A) Φ
(B) ε
(C) a
(D) {a, ε}
Answer (B)
The given alphabet ∑ contains only one symbol {a} and the given NFA accepts all strings
with any number of occurrences of ‘a’. In other words, the NFA accepts a+. Therefore
complement of the language accepted by automata is empty string.
5) Given the language L = {ab, aa, baa}, which of the following strings are in L*?
….1) abaabaaabaa
….2) aaaabaaaa
….3) baaaaabaaaab
….4) baaaaabaa
(A) 1, 2 and 3
(B) 2, 3 and 4
(C) 1, 2 and 4
(D) 1, 3 and 4
Answer (C)
Any combination of strings in set {ab, aa, baa} will be in L*.
….1) “abaabaaabaa” can be partitioned as a combination of strings in set {ab, aa, baa}. The
partitions are “ab aa baa ab aa”
….2) “aaaabaaaa” can be partitioned as a combination of strings in set {ab, aa, baa}. The
partitions are “aa ab aa aa”
….3) “baaaaabaaaab” cannot be partitioned as a combination of strings in set {ab, aa, baa}
….4) “baaaaabaa” can be partitioned as a combination of strings in set {ab, aa, baa}. The
partitions are “baa aa ab aa”
Answer (D)
….1) Is a variation of Turing Machine Halting problem and it is undecidable.
….2) Context Free Languages are not closed under intersection and complement. See this for
details.
….3) Complement of Regular languages is also regular. Then a DFA that accepts the
complement of L, i.e. ∑* – L, can be obtained by swapping its accepting states with its non-
accepting states.
….4) Recursive Languages are closed under complement. See this for details.
7) Consider the set of strings on {0,1} in which, every substring of 3 symbols has at most two
zeros. For example, 001110 and 011001 are in the language, but 100010 is not. All strings of
length less than 3 are also in the language. A partially completed DFA that accepts this
language is shown below.
8) The lexical analysis for a modern language such as Java needs the power of which one of
the following machine models in a necessary and sufficient sense?
(A) Finite state automata
(B) Deterministic pushdown automata
(C) Non-deterministic pushdown automata
(D) Turing machine
Answer (A)
Lexical analysis is the first step in compilation. In lexical analysis, program is divided into
tokens. Lexical analyzers are typically based on finite state automata. Tokens can typically be
expressed as different regular expressions:
An identifier is given by [a-zA-Z][a-zA-Z0-9]*
The keyword if is given by if.
Integers are given by [+-]?[0-9]+.
Answer (B)
DPDA cannot handle languages or grammars with ambiguity, but NDPDA can handle
languages with ambiguity and any context-free grammar
10) A deterministic finite automation (DFA)D with alphabet ∑= {a,b} is given below
Which of the following finite state machines is a valid minimal DFA which accepts the same
language as D?
Answer (A)
Options (B) and (C) are invalid because they both accept ‘b’ as a string which is not accepted
by give DFA. D is invalid because it accepts bb+a which are not accepted by given DFA.
Statement-1: If X union of ‘Y’ is uncountable, then both set ‘X’ and set ‘Y’ must be
uncountable.
Statement-2: The Cartesian product of two countable sets ‘X’ and ‘Y’ is countable.
Explanation:
Statement-1 is not correct, because only one set can be uncountable but need not be both.
Statement-2 is correct, because Cartesian product of two countable set is countable.
(A) only X
(B) only Y
(C) both X and Z
(D) both X and Y
Explanation:
X is decidable problem because, you can check regular grammar with the help of some
productions. So, this statement is correct.
Y is not correct, for counterexample P= null and Q= {anbn | n ≤ 0} then, P.Q= null which is
regular.
Z is also not correct because, Pumping lemma can prove that the language is not regular but
can not prove that the language is regular.
13): Consider three decision problems X, Y, and Z. It is known that X is decidable and Y is
undecidable then which is the following is true?
Explanation:
Suppose there are two problems, A and B. If A is undecidable and reducible to B then, B is
also undecidable and if B is decidable and and reducible to A then A is also decidable.
Explanation:
Option (B) is correct since, Turing machine can compute any mathematical operation.
Option (C) is also correct since, number of steps are give so it is decidable.
15) S –> aSa| bSb| a| b ;The language generated by the above grammar over the alphabet
{a,b} is the set of
(A) All palindromes.
(B) All odd length palindromes.
(C) Strings that begin and end with the same symbol
(D) All even length palindromes.
Answer (B)
The strings accepted by language are {a, b, aaa, bbb, aba, bab, ..}. All of these strings are odd
length palindromes.
16) 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)*?
(A) The set of all strings containing the substring 00.
(B) The set of all strings containing at most two 0’s.
(C) The set of all strings containing at least two 0’s.
(D) The set of all strings that begin and end with either 0 or 1.
Answer (C)
The regular expression has two 0’s surrounded by (0+1)* which means accepted strings must
have at least 2 0’s.
Answer (C)
The language L1 accept strings {c, abc, abcab, aabbcab, aabbcaabb, …} and L2 accept
strings {a, b, c, ab, abc, aabc, aabbc, … }. Intersection of these two languages is L1 ∩L2 =
{akbkc | k >= 0} which is context free, but not regular.
1. Regular expression for all strings starts with ‘ab’ and ends with ‘aa’ is
3. What is the minimum number of states in a DFA that recognizes the set of all binary strings that
a) 6 (b) 5 c) 4 (d) 3
a) Recursive Language
5. For a give Moore Machine, Given Input=’101010’, thus the output would be of length:
predicted
6. How many states will be there for the minimum state DFA accepting the language a*bba.
a) 2 b) 3 c) 4 d) 5
a) Pumping lemma (b) Turing machine c) Context free grammar (d) Push down automata