0% found this document useful (0 votes)
36 views25 pages

Flat questions

The document contains a series of questions and answers related to formal languages, automata theory, and computational complexity. It discusses properties of various language classes, decidability, and the capabilities of different computational models such as Turing machines, finite automata, and pushdown automata. The answers provided include explanations and justifications based on theoretical concepts in computer science.

Uploaded by

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

Flat questions

The document contains a series of questions and answers related to formal languages, automata theory, and computational complexity. It discusses properties of various language classes, decidability, and the capabilities of different computational models such as Turing machines, finite automata, and pushdown automata. The answers provided include explanations and justifications based on theoretical concepts in computer science.

Uploaded by

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

Flat questions

1) A is given a R.E. set L1 accepted by some Turing Machine M1. He is also


given that L1 is a R.E. set that is not recursive.
(a) L1 is always decidable
(b) L1 is partially decidable
(c) L1 is undecidable
(d) L1 can be accepted by the finite union of 1000 counter machines
Ans (d)
Ans : (c)
Sol : As the R.E. sets are not closed under complement, L1 cannot be accepted
by a Turing machine. A multi counter Turing machine is just a variation of
the standard model of a Turing machine.

2) A argues that as the membership problem of regular sets is decidable, if


we form the infinite union of regular sets we should decide the
membership problem. Choose the correct statement.
(a) A’s statement is always true
(b) A’s statement is always false
(c) A’ s statement is never true for any particular choice of regular
sets.
(d) none of the above
Ans : (a)
Sol : (a) The infinite union of regular sets can yield any formal languages
including undecidable once.
(b) If we choose all regular sets as {Σ} then Lavanya’s statement is true.
(c) If we choose all regular sets as if then Lavanya’s statement is true.

3)Consider a language L1 generated by a CSG G1 & a language L2


accepted by a non-deterministic LBA M2. Choose the correct statement.
(a) It is undecidable whether L1 is empty, finite, infinite of the same as
Σ*.

(b) It is undecidable if a given strings w is generated by G1 or accepted


by G1 or accepted by M2.
(c) It is decidable if L1 = L2 or L1 < L2.
(d) It is decicable if L1 or L2 is accepted by some two way
nondeterministic finite automata (2NFA)M3.
Ans : (a)
Sol : (a) A CSL can be obtained from the intersection of two CFLs, as the
Boolen closured two CFLs are the CSLs. Now the intersection of two
CFLs give the valid computations of a Turing Machine & so the given
choice reduces to the halting problem which is undecidable. So (a) is ture
statement.
(b) The CSLs are automatically recursive sets, so their membership
problem is decidable. So this is a false statement.
(c) The equivalence problem of two CFLs is undecidable, so this gives
that the equivalence problem of CFLs is undecidable. So this is a
false statement.
(d) It is undecidable if a CFL is regular, so this is undecidable.

4)Choose the correct statement in relation to a given instance P of a post


corresponding problem.
(a) P can be simulated by the intersection of two deterministic push
down automata.
(b) P can be simulated by the intersection of two regular sets.
(c) P cannot be reduced to the emptiness problem of context sensitive
languages (CSLs)
(d) P can be simulated by the intersection of two languages L1 & L2,
where L1 is generated by an LR(k) grammar & L2 is a language for
which a description as a regular expression R exists.
Ans : (a)
Sol : (a) The intersection of two DCFLs gives the valid computations of a
Turing Machine which corresponds to solutions to the PCP
problem P. So this is true.
(b) The intersection of two regular sets is regular. For a regular set we
have a FA M accepting it. The halting problem of M is decidable.
So this is a false statement.

5)A is given a software package S1. To test it exhaustively he generates test


data using a form counter machine. Choose the correct statement.
(a) By generating enough test data, S1 can be exhaustively tested, so
it is a decidable problem.
(b) Exhaustive testing is an undecidable problem.
(c) Though exhaustive testing is undecidable we can use enough test
data to see if that S1 contains < 10 bugs.
(d) none of the above.
Ans : (b)
Sol : Exhaustive testing reduce to the halting problem of turing machine. So we
can never decide if S1 will ever halt.

6)Which of the following statement is false


(a) A Turing machine is more powerful than a finite state machine
because it has halt state.
(b) A finite state machine can be assumed to be a Turing machine of
finite tape length, with rewinding capability and unidirectional tape
movement.
(c) both (a) and (b)
(d) none of the above
Ans : (c)
Sol : Any automata has a halt state. A TM is not a FA.

7)Choose the correct statement


(a) If any problem in P is closed under complement, then P = NP.
(b) If every problem in NP is closed under complement, then P = NP.
(c) If every problem in NP is NP – complete, then P = NP.
(d) If any problem in NP is not NP – complete, then P – NP.
Ans (b)
Sol : P is closed under complement. If the class NP is closed under
complement than P = NP.

8)The languages accepted by M is


(a) {00n
| n > 0}
(b) {0n10n1 | n > 1}
(c) {0n1 0n1 | n > 1}
(d) {0n10n1 | n > 1}
Ans (c)
Sol : The string must end with a 0. The 1 takes it back to q0& hence we take
0n10n.

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.

10)Consider an arbitrary C program which has some assignment statement


a. Choose the correct statement.
(a) It is decidable whether a is executed.
(b) It is undecidable whether a is live or dead always
(c) It is decidable if a is repeatedly executed in some iteration.
(d) None of the above
Ans (b)
Sol : (a) Whether ‘a’ is ever executed reduces the halting problem of Turing
machines & so is undecidable.
(b) Whether ‘a’ is live or dead reduces the hating problem of turing
machine
(c) It is undecidable if C contains a repeated iteration.

April 2018 cs352


December 2019
1) 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.
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

Answer: (d) 15 states

8) Which one of these given regular expressions isn’t equivalent to this


regular expression:

(m + n + o) *

a. (m*n* + o*)*

b. ((mn)* + o*)*

c. (m*n*o*)*

d. (m* + n* + o*)*

Answer: (b) ((mn)* + o*)*

9) The language that a Pushdown Automation accepts in which the stack


stays limited to about 10 items is described best as:

a. Recursive

b. Deterministic Context Free


c. Regular

d. Context Free

Answer: (c) Regular

10) The C language is a:

a. Regular language

b. Context free language

c. Language parsable fully by a Turing machine only

d. Context sensitive language

Answer: (b) Context free 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

(ii) |xy| n , where n is some positive integer and |w| n

(iii) for every i 0, the string xyiz is also in L.

From the question,

when x = b10+12k

then minimum possible string is = b10 or 'bbbbbbbbbb'.

we cannot divide this into three parts x, y, z.

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

2) Consider the languages L1={0i1j | i != j}, L2={0i1j | i = j}, L3 = {0i1j | i = 2j+1}, L4 =


{0i1j | i != 2j}. Which one of the following statements is true?
(A) Only L2 is context free
(B) Only L2 and L3 are context free
(C) Only L1 and L2 are context free
(D) All are context free

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”

6) Which of the following problems are decidable?


….1) Does a given program ever produce an output?
….2) If L is a context-free language, then is L’ (complement of L) also context-free?
….3) If L is a regular language, then is L’ also regular?
….4) If L is a recursive language, then, is L’ also recursive?
(A) 1, 2, 3, 4
(B) 1, 2,
(C) 2, 3, 4
(D) 3, 4

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.

The missing arcs in the DFA are


Answer (D)
State ‘q’ is trap state. All other states are accept states. In state 00, DFA must move to ‘q’ for
input symbol 0. All (non-trap) states indicate names indicate the characters seen before
reaching that particular state. Option (D) is the only option that follow these rules.

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]+.

9) Which of the following pairs have DIFFERENT expressive power?


(A) Deterministic finite automata (DFA) and Non-Deterministic finite automata(NFA)
(B) Deterministic push down automata (DPDA) and Non-deterministic pushdown automata
(C) Deterministic single-tape Turing machine and Non-deterministic single-tape Turing
Machine
(D) Single-tape Turing machine and multi-tape Turing machine

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.

11): Consider the following two statements with respect to Countability:

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

Which of the following option is true ?

(A) only statement 1


(B) only statement 2
(C) both the statements are true
(D) none

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.

Option (B) is true.

12): Consider the following statements:

 X: Given a grammar, checking if the grammar is not regular is decidable problem.

 Y: If P is regular and Q is not regular then, (P.Q) is necessarily non-regular.


 Z: Pumping lemma can be used for prove that the given language is regular.

Which of the following is true?

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

So, option (A) is true.

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?

(A) Z is decidable if X is reducible to Z


(B) Z is undecidable if Z is reducible to Y
(C) Z is undecidable if Y is reducible to Z
(D) Z is decidable if Z i reducible to Y’s complement.

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.

So, option (C) is correct.

14): Which of the following is decidable?

(A) A Turing machine prints specific letter.


(B) A Turing machine computes product of two numbers.
(C) An arbitrary Turing machine halts after fifty steps.
(D) none of the above.

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.

Both option (B) and (C) are correct.

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.

17) 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.

18) . 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.

1. Regular expression for all strings starts with ‘ab’ and ends with ‘aa’ is

a) ab(a+b)*aa* (b) ab(a+b)*aa c) ab*aa (d) a*b*aa

2. What is the language accepted by the following regular expression, 0*(1(01*0)*1)0*0* ?

a) Binary representation of multiples of 6

(b) Binary representation of multiples of 4

c) Binary representation of multiples of 3

(d) Binary representation of multiples of 2

3. What is the minimum number of states in a DFA that recognizes the set of all binary strings that

contains four consecutive 1’s?

a) 6 (b) 5 c) 4 (d) 3

4. The language accepted by Push down Automaton:

a) Recursive Language

(b) Context free language

c) Linearly Bounded language


(d) All of the mentioned

5. For a give Moore Machine, Given Input=’101010’, thus the output would be of length:

a) |Input|+1 (b) |Input| c) |Input|-1 (d) Cannot be

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

7. Pigeonhole principle is the underlying principle of

a) Pumping lemma (b) Turing machine c) Context free grammar (d) Push down automata

You might also like