0% found this document useful (0 votes)
608 views

TOC MCQs

The document provides multiple choice questions and explanations about theory of computation topics including automata fundamentals, finite automata, and deterministic finite automata. Some key details covered are: - A partially ordered relation is reflexive and transitive. - The minimum number of states required to recognize an octal number divisible by 3 is 3. - A finite automaton can be represented graphically using nodes for states and edges for transitions. - A deterministic finite automaton (DFA) can be represented using a 5-tuple including states, input alphabet, transition function, initial state, and final/acceptance states.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
608 views

TOC MCQs

The document provides multiple choice questions and explanations about theory of computation topics including automata fundamentals, finite automata, and deterministic finite automata. Some key details covered are: - A partially ordered relation is reflexive and transitive. - The minimum number of states required to recognize an octal number divisible by 3 is 3. - A finite automaton can be represented graphically using nodes for states and edges for transitions. - A deterministic finite automaton (DFA) can be represented using a 5-tuple including states, input alphabet, transition function, initial state, and final/acceptance states.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 84

www.rejinpaul.

com

CS8501 THEORY OF COMPUTATION

MULTIPLE CHOICE QUESTIONS (MCQ)

UNIT I AUTOMATA FUNDAMENTALS

TOPIC 1 : Introduction to formal proof

1. Assume the R is a relation on a set A, aRb is partially ordered such that a and b are

a) reflexive
b) transitive
c) symmetric
d) reflexive and transitive

Answer: d
Explanation: A partially ordered relation refers to one which is Reflexive, Transitive and
Antisymmetric.

2. The non- Kleene Star operation accepts the following string of finite length over
set A = {0,1} | where string s contains even number of 0 and 1
a) 01,0011,010101
b) 0011,11001100
c) ε,0011,11001100
d) ε,0011,11001100

Answer: b
Explanation: The Kleene star of A, denoted by A*, is the set of all strings obtained by
concatenating zero or more strings from A.

3. A regular language over an alphabet ∑ is one that cannot be obtained from the
basic languages using the operation
a) Union
b) Concatenation
c) Kleene*
d) All of the mentioned

Answer: d
Explanation: Union, Intersection, Concatenation, Kleene*, Reverse are all the closure
properties of Regular Language.

Download Rejinpaul App from Playstore


www.rejinpaul.com

4. Statement 1: A Finite automata can be represented graphically;


Statement 2: The nodes can be its states;
Statement 3: The edges or arcs can be used for transitions
Hint: Nodes and Edges are for trees and forests too.
Which of the following make the correct combination?
a) Statement 1 is false but Statement 2 and 3 are correct
b) Statement 1 and 2 are correct while 3 is wrong
c) None of the mentioned statements are correct
d) All of the mentioned

Answer: d
Explanation: It is possible to represent a finite automaton graphically, with nodes for
states, and arcs for transitions.

5. The minimum number of states required to recognize an octal number divisible by


3 are/is
a) 1
b) 3
c) 5
d) 7

Answer: b
Explanation: According to the question, minimum of 3 states are required to recognize
an octal number divisible by 3.

6. Which of the following is a not a part of 5-tuple finite automata?


a) Input alphabet
b) Transition function
c) Initial State
d) Output Alphabet

Answer: d
Explanation: A FA can be represented as FA= (Q, ∑, δ, q0, F) where Q=Finite Set of
States, ∑=Finite Input Alphabet, δ=Transition Function, q0=Initial State,
F=Final/Acceptance State).

7. If an Infinite language is passed to Machine M, the subsidiary which gives a finite


solution to the infinite input tape is
a) Compiler
b) Interpreter
c) Loader and Linkers
d) None of the mentioned

Download Rejinpaul App from Playstore


www.rejinpaul.com

Answer: a
Explanation: A Compiler is used to give a finite solution to an infinite phenomenon.
Example of an infinite phenomenon is Language C, etc.

8. The number of elements in the set for the Language L={xϵ(∑r) *|length if x is at
most 2} and ∑={0,1} is
a) 7
b) 6
c) 8
d) 5
Answer: a
Explanation: ∑r= {1,0} and a Kleene* operation would lead to the following
set=COUNT{ε,0,1,00,11,01,10} =7.

9. For the following change of state in FA, which of the following codes is an
incorrect option?
a) δ (m, 1) =n
b) δ (0, n) =m
c) δ (m,0) =ε
d) s: accept = false; cin >> char;
if char = “0” goto n;
Answer: b
Explanation: δ(QX∑) = Q1 is the correct representation of change of state. Here, δ is
called the Transition function.

10. Given: ∑= {a, b}


L= {xϵ∑*|x is a string combination}
∑4 represents which among the following?
a) {aa, ab, ba, bb}
b) {aaaa, abab, ε, abaa, aabb}
c) {aaa, aab, aba, bbb}
d) All of the mentioned
Answer: b
Explanation: ∑* represents any combination of the given set while ∑x represents the
set of combinations with length x where x ϵ I.

TOPIC 2: Finite Automata


1. There are tuples in finite state machine.
a) 4
b) 5
c) 6
d) unlimited

Download Rejinpaul App from Playstore


www.rejinpaul.com

SOLUTION
Answer: b
Explanation: States, input symbols,initial state,accepting state and transition
function.
2. Transition function maps.
a) Σ * Q -> Σ
b) Q * Q -> Σ
c) Σ * Σ -> Q
d) Q * Σ -> Q
SOLUTION
Answer: d
Explanation: Inputs are state and input string output is states.
3. Number of states require to accept string ends with 10.
a) 3
b) 2
c) 1
d) can’t be represented.
SOLUTION
Answer: a
Explanation: This is minimal finite automata.
4. Extended transition function is .
a) Q * Σ* -> Q
b) Q * Σ -> Q
c) Q* * Σ* -> Σ
d) Q * Σ -> Σ
SOLUTION
Answer: a
Explanation: This takes single state and string of input to produce a state.
5. δ*(q,ya) is equivalent to .
a) δ((q,y),a)
b) δ(δ*(q,y),a)
c) δ(q,ya)
d) independent from δ notation
SOLUTION
Answer: b
Explanation: First it parse y string after that it parse a.
6. String X is accepted by finite automata if .
a) δ*(q,x) E A
b) δ(q,x) E A
c) δ*(Q0,x) E A
d) δ(Q0,x) E A
SOLUTION

Download Rejinpaul App from Playstore


www.rejinpaul.com

Answer: c
Explanation: If automata starts with starting state and after finite moves if reaches
to final step then it called accepted.
7. Languages of a automata is
a) If it is accepted by automata
b) If it halts
c) If automata touch final state in its life time
d) All language are language of automata
SOLUTION
Answer: a
Explanation: If a string accepted by automata it is called language of automata.
8. Language of finite automata is.
a) Type 0
b) Type 1
c) Type 2
d) Type 3
SOLUTION
Answer: d
Explanation: According to Chomsky classification.
9. Finite automata requires minimum number of stacks.
a) 1
b) 0
c) 2
d) None of the mentioned
SOLUTION
Answer: b
Explanation: Finite automata doesn’t require any stack operation .
10. Number of final state require to accept Φ in minimal finite automata.
a) 1
b) 2
c) 3
d) None of the mentioned
SOLUTION
Answer: d
Explanation: No final state requires.
11. Regular expression for all strings starts with ab and ends with bba is.
a) aba*b*bba
b) ab(ab)*bba
c) ab(a+b)*bba
d) All of the mentioned
SOLUTION
Answer: c

Download Rejinpaul App from Playstore


www.rejinpaul.com

Explanation: Starts with ab then any number of a or b and ends with bba.
12. How many DFA’s exits with two states over input alphabet {0,1} ?
a) 16
b) 26
c) 32
d) 64
SOLUTION
Answer: d
Explanation: Number of DFA’s = 2n * n(2*n).
13. The basic limitation of finite automata is that
a) It can’t remember arbitrary large amount of information.
b) It sometimes recognize grammar that are not regular.
c) It sometimes fails to recognize regular grammar.
d) All of the mentioned
SOLUTION
Answer: a
Explanation:Because there is no memory associated with automata.
14. Number of states require to simulate a computer with memory capable of storing ‘3’
words each of length ‘8’.
a) 3 * 28
b) 2(3*8)
c) 2(3+8)
d) None of the mentioned
SOLUTION
Answer: b
Explanation: 2(m*n) states requires .
15. FSM with output capability can be used to add two given integer in binary
representation. This is
a) True
b) False
c) May be true
d) None of the mentioned
SOLUTION
Answer: a
Explanation: Use them as a flip flop output .

TOPIC 3: Deterministic Finite Automata


1. Which of the following not an example Bounded Information?
a) fan switch outputs {on, off}
b) electricity meter reading
c) colour of the traffic light at the moment
d) none of the mentioned

Download Rejinpaul App from Playstore


www.rejinpaul.com

SOLUTION
Answer: b
Explanation: Bounded information refers to one whose output is limited and it
cannot be said what were the recorded outputs previously until memorized.
2. A Language for which no DFA exist is a
a) Regular Language
b) Non-Regular Language
c) May be Regular
d) Cannot be said
SOLUTION
Answer: b
Explanation: A language for which there is no existence of a deterministic finite
automata is always Non Regular and methods like Pumping Lemma can be used to
prove the same.
3. A DFA cannot be represented in the following format
a) Transition graph
b) Transition Table
c) C code
d) None of the mentioned
SOLUTION
Answer: d
Explanation: A DFA can be represented in the following formats: Transition Graph,
Transition Table, Transition tree/forest/Any programming Language.
4. What the following DFA accepts?

Download Rejinpaul App from Playstore


www.rejinpaul.com

a) x is a string such that it ends with ‘101’


b) x is a string such that it ends with ‘01’
c) x is a string such that it has odd 1’s and even 0’s
d) x is a strings such that it has starting and ending character as 1
SOLUTION
Answer: a
Explanation: Strings such as {1101,101,10101} are being accepted while {1001,11001}
are not. Thus, this conclusion leads to option a.
5. When are 2 finite states equivalent?
a) Same number of transitions
b) Same number of states
c) Same number of states as well as transitions
d) Both are final states
SOLUTION
Answer: c
Explanation: Two states are said to be equivalent if and only if they have same
number of states as well as transitions.
6. What does the following figure most correctly represents?

a) Final state with loop x


b) Transitional state with loop x
c) Initial state as well as final state with loop x
d) Insufficient Data
SOLUTION
Answer: c
Explanation: The figure represents the initial as well as the final state with an
iteration of x.
7. Which of the following will not be accepted by the following DFA?

Download Rejinpaul App from Playstore


www.rejinpaul.com

a) ababaabaa
b) abbbaa
c) abbbaabb
d) abbaabbaa
SOLUTION
Answer: a
Explanation: All the Strings are getting accepted except ‘ababaabaa’ as it is directed
to dumping state. Dumping state also refers to the reject state of the automata.
8. Which of the following will the given DFA won’t accept?

a) ε
b) 11010
c) 10001010
d) String of letter count 11

10

Download Rejinpaul App from Playstore


www.rejinpaul.com

SOLUTION
Answer: a
Explanation: As the initial state is not made an acceptance state, thus ε will not be
accepted by the given DFA. For the automata to accept ε as an entity, one should
make the initial state as also the final state.
9. Can a DFA recognize a palindrome number?
a) Yes
b) No
c) Yes, with input alphabet as ∑*
d) Can’t be determined
SOLUTION
Answer: b
Explanation: Language to accept a palindrome number or string will be non-regular
and thus, its DFA cannot be obtained. Though, PDA is possible.
10. Which of the following is not an example of finite state machine system?
a) Control Mechanism of an elevator
b) Combinational Locks
c) Traffic Lights
d) Digital Watches
SOLUTION
Answer: d
Explanation: Proper and sequential combination of events leads the machines to
work in hand which includes The elevator, Combinational Locks, Traffic Lights,
vending machine, etc. Other applications of Finite machine state system are
Communication Protocol Design, Artificial Intelligence Research, A Turnstile, etc.

TOPIC 4: Non-deterministic Finite Automata

1. Which of the following options is correct?


Statement 1: Initial State of NFA is Initial State of DFA.
Statement 2: The final state of DFA will be every combination of final state of NFA.
a) Statement 1 is true and Statement 2 is true
b) Statement 1 is true and Statement 2 is false
c) Statement 1 can be true and Statement 2 is true
d) Statement 1 is false and Statement 2 is also false
SOLUTION
Answer: a
Explanation: Statement 1 and 2 always true for a given Language.
2. Given Language: L= {ab U aba}*
If X is the minimum number of states for a DFA and Y is the number of states to
construct the NFA,
|X-Y|=?

11

Download Rejinpaul App from Playstore


www.rejinpaul.com

a) 2
b) 3
c) 4
d) 1
SOLUTION
Answer: a
Explanation: Construct the DFA and NFA individually, and the attain the difference of
states.
3. An automaton that presents output based on previous state or current input:
a) Acceptor
b) Classifier
c) Transducer
d) None of the mentioned.
SOLUTION
Answer: c
Explanation: A transducer is an automaton that produces an output on the basis of
what input has been given currently or previous state.
4. If NFA of 6 states excluding the initial state is converted into DFA, maximum possible
number of states for the DFA is ?
a) 64
b) 32
c) 128
d) 127
SOLUTION
Answer: c
Explanation: The maximum number of sets for DFA converted from NFA would be
not greater than 2n.
5. NFA, in its name has ’non-deterministic’ because of :
a) The result is undetermined
b) The choice of path is non-deterministic
c) The state to be transited next is non-deterministic
d) All of the mentioned
SOLUTION
Answer: b
Explanation: Non deterministic or deterministic depends upon the definite path
defined for the transition from one state to another or undefined(multiple paths).
6. Which of the following is correct proposition?
Statement 1: Non determinism is a generalization of Determinism.
Statement 2: Every DFA is automatically an NFA
a) Statement 1 is correct because Statement 2 is correct
b) Statement 2 is correct because Statement 2 is correct
c) Statement 2 is false and Statement 1 is false

12

Download Rejinpaul App from Playstore


www.rejinpaul.com

d) Statement 1 is false because Statement 2 is false


SOLUTION
Answer: b
Explanation: DFA is a specific case of NFA.
7. Given Language L= {xϵ {a, b}*|x contains aba as its substring}
Find the difference of transitions made in constructing a DFA and an equivalent NFA?
a) 2
b) 3
c) 4
d) Cannot be determined.
SOLUTION
Answer: a
Explanation: The individual Transition graphs can be made and the difference of
transitions can be determined.
8. The construction time for DFA from an equivalent NFA (m number of node)is:
a) O(m2)
b) O(2m)
c) O(m)
d) O(log m)
SOLUTION
Answer: b
Explanation: From the coded NFA-DFA conversion.
9. If n is the length of Input string and m is the number of nodes, the running time of
DFA is x that of NFA.Find x?
a) 1/m2
b) 2m
c) 1/m
d) log m
SOLUTION
Answer: a
Explanation: Running time of DFA: O(n) and Running time of NFA =O(m2n).
10. Which of the following option is correct?
a) NFA is slower to process and its representation uses more memory than DFA
b) DFA is faster to process and its representation uses less memory than NFA
c) NFA is slower to process and its representation uses less memory than DFA
d) DFA is slower to process and its representation uses less memory than NFA
SOLUTION
Answer: c
Explanation: NFA, while computing strings, take parallel paths, make different copies
of input and goes along different paths in order to search for the result. This creates
the difference in processing speed of DFA and NFA.

13

Download Rejinpaul App from Playstore


www.rejinpaul.com

TOPIC 5: Finite Automata with Epsilon Transitions


1. According to the given transitions, which among the following are the epsilon
closures of q1 for the given NFA?
Δ (q1, ε) = {q2, q3, q4}
Δ (q4, 1) =q1
Δ (q1, ε) =q1
a) q4
b) q2
c) q1
d) q1, q2, q3, q4
SOLUTION
Answer: d
Explanation: The set of states which can be reached from q using ε-transitions, is
called the ε-closure over state q.
2. State true or false?
Statement: An NFA can be modified to allow transition without input alphabets, along
with one or more transitions on input symbols.
a) True
b) False
SOLUTION
Answer: a
Explanation: It is possible to construct an NFA with ε-transitions, presence of no
input symbols, and that is called NFA with ε-moves.
3. State true or false?
Statement: ε (Input) does not appears on Input tape.
a) True
b) False
Answer: a
SOLUTION
Explanation: ε does not appears on Input tape, ε transition means a transition
without scanning a symbol i.e. without moving the read head.
4. Statement 1: ε- transition can be called as hidden non-determinism.
Statement 2: δ (q, ε) = p means from q it can jump to p with a shift in read head.
Which among the following options is correct?
a) Statement 1 and 2, both are correct
b) Statement 1 and 2, both are wrong
c) Statement 1 is correct while Statement 2 is wrong
d) Statement 1 is wrong while Statement 2 is correct
SOLUTION
Answer: c
Explanation: The transition with ε leads to a jump but without any shift in read head.
Further, the method can be called one to introduce hidden non-determinism.

14

Download Rejinpaul App from Playstore


www.rejinpaul.com

5. ε- closure of q1 in the given transition graph:


a) {q1}
b) {q0, q2}
c) {q1, q2}
d) {q0, q1, q2}
SOLUTION
Answer: c
Explanation: ε-closure is defined as the set of states being reached through
ε-transitions from a starting state.
6. Predict the total number of final states after removing the ε-moves from the given
NFA?
a) 1
b) 2
c) 3
d) 0
SOLUTION
Answer: c
Explanation: The NFA which would result after eliminating ε-moves can be shown
diagramatically.
7. For NFA with ε-moves, which among the following is correct?
a) Δ: Q X (∑ U {ε}) -> P(Q)
b) Δ: Q X (∑) -> P(Q)
c) Δ: Q X (∑*) -> P(Q)
d) All of the mentioned
SOLUTION
Answer: a
Explanation: Due to the presence of ε symbol, or rather an epsilon-move, the input
alphabets unites with it to form a set including ε.
8. Which among the following is false?
ε-closure of a subset S of Q is:
a) Every element of S ϵ Q
b) For any q ϵ ε(S), every element of δ (q, ε) is in ε(S)
c) No other element is in ε(S)
d) None of the mentioned
SOLUTION
Answer: d
Explanation: All the mentioned are the closure properties of ε and encircles all the
elements if it satisfies the following options:
a) Every element of S ϵ Q
b) For any q ϵ ε(S), every element of δ (q, ε) is in ε(S)
c) No other element is in ε(S)
9. The automaton which allows transformation to a new state without consuming any

15

Download Rejinpaul App from Playstore


www.rejinpaul.com

input symbols:
a) NFA
b) DFA
c) NFA-l
d) All of the mentioned
SOLUTION
Answer: c
Explanation: NFA-l or e-NFA is an extension of Non deterministic Finite Automata
which are usually called NFA with epsilon moves or lambda transitions.
10. e-transitions are
a) conditional
b) unconditional
c) input dependent
d) none of the mentioned
SOLUTION
Answer: b
Explanation: An epsilon move is a transition from one state to another that doesnt
require any specific condition.
11. The of a set of states, P, of an NFA is defined as the set of states
reachable from any state in P following e-transitions.
a) e-closure
b) e-pack
c) Q in the tuple
d) None of the mentioned
SOLUTION
Answer: a
Explanation: The e-closure of a set of states, P, of an NFA is defined as the set of
states reachable from any state in P following e-transitions.
12. The e-NFA recognizable languages are not closed under :
a) Union
b) Negation
c) Kleene Closure
d) None of the mentioned
SOLUTION
Answer: d
Explanation: The languages which are recognized by an epsilon Non deterministic
automata are closed under the following operations:
a) Union
b) Intersection
c) Concatenation
d) Negation
e) Star

16

Download Rejinpaul App from Playstore


www.rejinpaul.com

f) Kleene closure

UNIT II REGULAR EXPRESSIONS AND LANGUAGES

TOPIC 1: Regular Expressions


1. L is a regular Language if and only If the set of classes of IL is finite.
a) Equivalence
b) Reflexive
c) Myhill
d) Nerode
SOLUTION
Answer: a
Explanation: According to Myhill Nerode theorem, the corollary proves the given
statement correct for equivalence classes.
2. A language can be generated from simple primitive language in a simple way if and
only if
a) It is recognized by a device of infinite states
b) It takes no auxiliary memory
c) Both are correct
d) Both are wrong
SOLUTION
Answer: b
Explanation: A language is regular if and only if it can be accepted by a finite
automaton. Secondly, It supports no concept of auxiliary memory as it loses the data
as soon as the device is shut down.
3. Which of the following does not represents the given language?
Language: {0,01}
a) 0+01
b) {0} U {01}
c) {0} U {0}{1}
d) {0} ^ {01}
SOLUTION
Answer: d
Explanation: The given option represents {0, 01} in different forms using set
operations and Regular Expressions. The operator like ^, v, etc. are logical operation
and they form invalid regular expressions when used.
4. According to the given language, which among the following expressions does it
corresponds to?
Language L={xϵ{0,1}|x is of length 4 or less}
a) (0+1+0+1+0+1+0+1)4
b) (0+1)4

17

Download Rejinpaul App from Playstore


www.rejinpaul.com

c) (01)4
d) (0+1+ε)4
SOLUTION
Answer: d
Explanation: The extended notation would be (0+1)4 but however, we may allow
some or all the factors to be ε. Thus ε needs to be included in the given regular
expression.
5. Which among the following looks similar to the given expression?
((0+1). (0+1)) *
a) {xϵ {0,1} *|x is all binary number with even length}
b) {xϵ {0,1} |x is all binary number with even length}
c) {xϵ {0,1} *|x is all binary number with odd length}
d) {xϵ {0,1} |x is all binary number with odd length}
SOLUTION
Answer: a
Explanation: The given regular expression corresponds to a language of binary
strings which is of even length including a length of 0.
6. If R represents a regular language, which of the following represents the Venn-
diagram most correctly?

a) An Irregular Set
b) R*
c) R complement
d) R reverse
SOLUTION
Answer: b
Explanation: The given diagram represents the Kleene operation over the Regular
Language R in which the final states become the initial and the initial state becomes
final.
7. The given NFA corresponds to which of the following Regular expressions?

a) (0+1) *(00+11) (0+1) *


b) (0+1) *(00+11) *(0+1) *
c) (0+1) *(00+11) (0+1)
d) (0+1) (00+11) (0+1) *
SOLUTION
Answer: a
Explanation: The transition states shown are the result of breaking down the given
regular expression in fragments. For dot operation, we change a state, for union
(plus) operation, we diverge into two transitions and for Kleene Operation, we apply a
loop.
8. Concatenation Operation refers to which of the following set operations:

18

Download Rejinpaul App from Playstore


www.rejinpaul.com

a) Union
b) Dot
c) Kleene
d) Two of the options are correct
SOLUTION
Answer: b
Explanation: Two operands are said to be performing Concatenation operation AB =
A•B = {xy: x ∈ A & y ∈ B}.
9. Concatenation of R with Ф outputs:
a) R
b) Ф
c) R.Ф
d) None of the mentioned
SOLUTION
Answer: b
Explanation: By distributive property (Regular expression identities), we can prove
the given identity to be Ф.
10. RR* can be expressed in which of the forms:
a) R+
b) R-
c) R+ U R-
d) R
SOLUTION
Answer: a
Explanation: RR*=R+ as R+ means the occurrence to be at least once.

TOPIC 2: FA and Regular Expressions


1. What kind of expressions do we used for pattern matching?
a) Regular Expression
b) Rational Expression
c) Regular & Rational Expression
d) None of the mentioned
SOLUTION
Answer: c
Explanation: In automata theory, Regular Expression(sometimes also called the
Rational Expression ) is a sequence or set of characters that define a search pattern,
mainly for the use in pattern matching with strings or string matching.
2. Which of the following do Regexps do not find their use in?
a) search engines
b) word processors
c) sed
d) none of the mentioned

19

Download Rejinpaul App from Playstore


www.rejinpaul.com

SOLUTION
Answer: d
Explanation: Regexp processors are found in several search engines, seach and
replace mechanisms, and text processing utilities.
3. Which of the following languages have built in regexps support?
a) Perl
b) Java
c) Python
d) C++
SOLUTION
Answer: a
Explanation: Many languages come with built in support of regexps like Perl,
Javascript, Ruby etc. While some provide support using standard libraries like .NET,
Java, Python, C++, C and POSIX.
4. The following is/are an approach to process a regexp:
a) Contruction of NFA and subsequently, a DFA.
b) Thompson’s Contruction Algorithm
c) Both (a) and (b)
d) None of the mentioned
SOLUTION
Answer: c
Explanation: A regexp processor translates the syntax into internal representation
which can be executed and matched with a string and that internal representation
can have several approaches like the ones mentioned.
5. Are the given two patterns equivalent?
(1) gray|grey
(2) gr(a|e)y
a) yes
b) no
SOLUTION
Answer: a
Explanation: Paranthesis can be used to define the scope and precedence of
operators. Thus, both the expression represents the same pattern.
6. Which of the following are not quantifiers?
a) Kleene plus +
b) Kleene star *
c) Question mark ?
d) None of the mentioned
SOLUTION
Answer: d
Explanation: A quantifier after a token specifies how often the preceding element is
allowed to occur. ?, *, +, {n}, {min, }, {min, max} are few quantifiers we use in regexps

20

Download Rejinpaul App from Playstore


www.rejinpaul.com

implementations.
7. Which of the following cannot be used to decide whether and how a given regexp
matches a string:
a) NFA to DFA
b) Lazy DFA algorithm
c) Backtracking
d) None of the mentioned
SOLUTION
Answer: d
Explanation: There are at least three algorithms which decides for us, whether and
how a regexp matches a string which included the transformation of Non
deterministic automaton to deterministic finite automaton, The lazy DFA algorithm
where one simulates the NFA directly, building each DFA on demand and then
discarding it at the next step and the process of backtracking whose running time is
exponential.
8. What does the following segment of code output?
$string1 = "Hello World\n";
if ($string1 =~ m/(H..).(l..)/) {
print "We matched '$1' and '$2'.\n";

}
a) We matched ‘Hel’ and ‘ld’
b) We matched ‘Hel’ and ‘lld’
c) We matched ‘Hel’ and ‘lo ‘
d) None of the mentioned
SOLUTION
Answer: c
Explanation: () groups a series of pattern element to a single element.
When we use pattern in parenthesis, we can use any of ‘$1’, ‘$2’ later to refer to the
previously matched pattern.
9. Given segment of code:
$string1 = "Hello\nWorld\n";
if ($string1 =~ m/d\n\z/) {
print "$string1 is a string ";
print "that ends with 'd\\n'.\n";

}
What does the symbol /z does?
a) changes line
b) matches the beginning of a string
c) matches the end of a string
d) none of the mentioned
SOLUTION

21

Download Rejinpaul App from Playstore


www.rejinpaul.com

Answer: c
Explanation: It matches the end of a string and not an internal line.The given
segment of code outputs:
Hello
World
is a string that ends with ‘d\n’
10. Conversion of a regular expression into its corresponding NFA :
a) Thompson’s Construction Algorithm
b) Powerset Construction
c) Kleene’s algorithm
d) None of the mentioned
SOLUTION
Answer: a
Explanation: Thompson construction algorithm is an algorithm in automata theory
used to convert a given regular expression into NFA. Similarly, Kleene algorithm is
used to convert a finite automaton to a regular expression.

TOPIC 3: Proving Languages not to be regular

1. Relate the following statement:


Statement: All sufficiently long words in a regular language can have a middle section
of words repeated a number of times to produce a new word which also lies within the
same language.
a) Turing Machine
b) Pumping Lemma
c) Arden’s theorem
d) None of the mentioned
SOLUTION
Answer: b
Explanation: Pumping lemma defines an essential property for every regular
language in automata theory. It has certain rules which decide whether a language is
regular or not.
2. While applying Pumping lemma over a language, we consider a string w that belong
to L and fragment it into parts.
a) 2
b) 5
c) 3
d) 6
SOLUTION
Answer: c
Explanation: We select a string w such that w=xyz and |y|>0 and other conditions.
However, there exists an integer n such that |w|>=n for any wÎL.

22

Download Rejinpaul App from Playstore


www.rejinpaul.com

3. If we select a string w such that w∈L, and w=xyz. Which of the following portions
cannot be an empty string?
a) x
b) y
c) z
d) all of the mentioned
SOLUTION
Answer: b
Explanation: The lemma says, the portion y in xyz cannot be zero or empty i.e. |y|>0,
this condition needs to be fulfilled to check the conclusion condition.
4. Let w= xyz and y refers to the middle portion and |y|>0.What do we call the process
of repeating y 0 or more times before checking that they still belong to the language L
or not?
a) Generating
b) Pumping
c) Producing
d) None of the mentioned
SOLUTION
Answer: b
Explanation: The process of repeatation is called pumping and so, pumping is the
process we perform before we check whether the pumped string belongs to L or not.
5. There exists a language L. We define a string w such that w∈L and w=xyz and |w|
>=n for some constant integer n.What can be the maximum length of the substring xy
i.e. |xy|<=?
a) n
b) |y|
c) |x|
d) none of the mentioned
SOLUTION
Answer: a
Explanation: It is the first conditional statement of the lemma that states that
|xy|<=n, i.e. the maximum length of the substring xy in w can be n only.
6. Fill in the blank in terms of p, where p is the maximum string length in L.
Statement: Finite languages trivially satisfy the pumping lemma by having n =
a) p*1
b) p+1
c) p-1
d) None of the mentioned
SOLUTION
Answer: b
Explanation: Finite languages trivially satisfy the pumping lemma by having n equal
to the maximum string length in l plus 1.

23

Download Rejinpaul App from Playstore


www.rejinpaul.com

7. Answer in accordance to the third and last statement in pumping lemma:


For all xyiz ∈L
a) i>0
b) i<0
c) i<=0
d) i>=0
SOLUTION
Answer: d
Explanation: Suppose L is a regular language . Then there is an integer n so that for
any x∈L and |x|>=n, there are strings u,v,w so that
x= uvw
|uv|<=n
|v|>0
for any m>=0, uvmw ∈L.
8. If d is a final state, which of the following is correct according to the given diagram?

a) x=p, y=qr, z=s


b) x=p, z=qrs
c) x=pr, y=r, z=s
d) All of the mentioned
SOLUTION
Answer: a
Explanation: The FSA accepts the string pqrs. In terms of pumping lemma, the string
pqrs is broken into an x portion an a, a y portion qr and a z portion s.
9. Let w be a string and fragmented by three variable x, y, and z as per pumping lemma.
What does these variables represent?
a) string count
b) string
c) both (a) and (b)
d) none of the mentioned
SOLUTION
Answer: a
Explanation: Given: w =xyz. Here, xyz individually represents strings or rather
substrings which we compute over conditions to check the regularity of the
language.
10. Which of the following one can relate to the given statement:
Statement: If n items are put into m containers, with n>m, then atleast one container
must contain more than one item.
a) Pumping lemma
b) Pigeon Hole principle
c) Count principle
d) None of the mentioned

24

Download Rejinpaul App from Playstore


www.rejinpaul.com

SOLUTION
Answer: b
Explanation: Pigeon hole principle states the following example: If there exists n=10
pigeons in m=9 holes, then since 10>9, the pigeonhole principle says that at least
one hole has more than one pigeon.

TOPIC 4: Proving Languages not to be regular (Pumping Lemma)


1. Relate the following statement:
Statement: All sufficiently long words in a regular language can have a middle section
of words repeated a number of times to produce a new word which also lies within the
same language.
a) Turing Machine
b) Pumping Lemma
c) Arden’s theorem
d) None of the mentioned
SOLUTION
Answer: b
Explanation: Pumping lemma defines an essential property for every regular
language in automata theory. It has certain rules which decide whether a language is
regular or not.
2. While applying Pumping lemma over a language, we consider a string w that belong
to L and fragment it into parts.
a) 2
b) 5
c) 3
d) 6
SOLUTION
Answer: c
Explanation: We select a string w such that w=xyz and |y|>0 and other conditions.
However, there exists an integer n such that |w|>=n for any wÎL.
3. If we select a string w such that w∈L, and w=xyz. Which of the following portions
cannot be an empty string?
a) x
b) y
c) z
d) all of the mentioned
SOLUTION
Answer: b
Explanation: The lemma says, the portion y in xyz cannot be zero or empty i.e. |y|>0,
this condition needs to be fulfilled to check the conclusion condition.

25

Download Rejinpaul App from Playstore


www.rejinpaul.com

4. Let w= xyz and y refers to the middle portion and |y|>0.What do we call the process
of repeating y 0 or more times before checking that they still belong to the language L
or not?
a) Generating
b) Pumping
c) Producing
d) None of the mentioned
SOLUTION
Answer: b
Explanation: The process of repeatation is called pumping and so, pumping is the
process we perform before we check whether the pumped string belongs to L or not.
5. There exists a language L. We define a string w such that w∈L and w=xyz and |w|
>=n for some constant integer n.What can be the maximum length of the substring xy
i.e. |xy|<=?
a) n
b) |y|
c) |x|
d) none of the mentioned
SOLUTION
Answer: a
Explanation: It is the first conditional statement of the lemma that states that
|xy|<=n, i.e. the maximum length of the substring xy in w can be n only.
6. Fill in the blank in terms of p, where p is the maximum string length in L.
Statement: Finite languages trivially satisfy the pumping lemma by having n =
a) p*1
b) p+1
c) p-1
d) None of the mentioned
SOLUTION
Answer: b
Explanation: Finite languages trivially satisfy the pumping lemma by having n equal
to the maximum string length in l plus 1.
7. Answer in accordance to the third and last statement in pumping lemma:
For all xyiz ∈L
a) i>0
b) i<0
c) i<=0
d) i>=0
SOLUTION
Answer: d
Explanation: Suppose L is a regular language . Then there is an integer n so that for
any x∈L and |x|>=n, there are strings u,v,w so that

26

Download Rejinpaul App from Playstore


www.rejinpaul.com

x= uvw
|uv|<=n
|v|>0
for any m>=0, uvmw ∈L.
8. If d is a final state, which of the following is correct according to the given diagram?

a) x=p, y=qr, z=s


b) x=p, z=qrs
c) x=pr, y=r, z=s
d) All of the mentioned
SOLUTION
Answer: a
Explanation: The FSA accepts the string pqrs. In terms of pumping lemma, the string
pqrs is broken into an x portion an a, a y portion qr and a z portion s.
9. Let w be a string and fragmented by three variable x, y, and z as per pumping lemma.
What does these variables represent?
a) string count
b) string
c) both (a) and (b)
d) none of the mentioned
SOLUTION
Answer: a
Explanation: Given: w =xyz. Here, xyz individually represents strings or rather
substrings which we compute over conditions to check the regularity of the
language.
10. Which of the following one can relate to the given statement:
Statement: If n items are put into m containers, with n>m, then atleast one container
must contain more than one item.
a) Pumping lemma
b) Pigeon Hole principle
c) Count principle
d) None of the mentioned
SOLUTION
Answer: b
Explanation: Pigeon hole principle states the following example: If there exists n=10
pigeons in m=9 holes, then since 10>9, the pigeonhole principle says that at least
one hole has more than one pigeon.
TOPIC 4: Closure Properties of Regular Languages
1. If L1, L2 are regular and op(L1, L2) is also regular, then L1 and L2 are said to be
under an operation op.
a) open
b) closed

27

Download Rejinpaul App from Playstore


www.rejinpaul.com

c) decidable
d) none of the mentioned
SOLUTION
Answer: b
Explanation: If two regular languages are closed under an operation op, then the
resultant of the languages over an operation op will also be regular.
2. Suppose a regular language L is closed under the operation halving, then the result
would be:
a) 1/4 L will be regular
b) 1/2 L will be regular
c) 1/8 L will be regular
d) Al of the mentioned
SOLUTION
Answer: d
Explanation: At first stage 1/2 L will be regular and subsequently, all the options will
be regular.
3. If L1′ and L2′ are regular languages, then L1.L2 will be
a) regular
b) non regular
c) may be regular
d) none of the mentioned
SOLUTION
Answer: a
Explanation: Regular language is closed under complement operation. Thus, if L1′
and L2′ are regular so are L1 and L2. And if L1 and L2 are regular so is L1.L2.
4. If L1 and L2′ are regular languages, L1 ∩ (L2′ U L1′)’ will be
a) regular
b) non regular
c) may be regular
d) none of the mentioned
SOLUTION
Answer: a
Explanation: If L1 is regular, so is L1′ and if L1′ and L2′ are regular so is L1′ U L2′.
Further, regular languages are also closed under intersection operation.
5. If A and B are regular languages, !(A’ U B’) is:
a) regular
b) non regular
c) may be regular
d) none of the mentioned
SOLUTION
Answer: a
Explanation: If A and B are regular languages, then A Ç B is a regular language and A

28

Download Rejinpaul App from Playstore


www.rejinpaul.com

∩ B is equivalent to !(A’ U B’).


6. Which among the following are the boolean operations that under which regular
languages are closed?
a) Union
b) Intersection
c) Complement
d) All of the mentioned
SOLUTION
Answer: d
Explanation: Regular languages are closed under the following operations:
a) Regular expression operations
b) Boolean operations
c) Homomorphism
d) Inverse Homomorphism
7. Suppose a language L1 has 2 states and L2 has 2 states. After using the cross
product construction method, we have a machine M that accepts L1 ∩ L2. The total
number of states in M:
a) 6
b) 4
c) 2
d) 8
SOLUTION
Answer: 4
Explanation: M is defined as: (Q, S, d, q0, F)
where Q=Q1*Q2 and F=F1*F2
8. If L is a regular language, then (L’)’ U L will be :
a) L
b) L’
c) f
d) none of the mentioned
SOLUTION
Answer: a
Explanation: (L’)’ is equivalent to L and L U L is subsequently equivalent to L.
9. If L is a regular language, then (((L’)r)’)* is:
a) regular
b) non regular
c) may be regular
d) none of the mentioned
SOLUTION
Answer: a
Explanation: If L is regular so is its complement, if L’ is regular so is its reverse, if (L’)r
is regular so is its Kleene.

29

Download Rejinpaul App from Playstore


www.rejinpaul.com

10. Which among the following is the closure property of a regular language?
a) Emptiness
b) Universality
c) Membership
d) None of the mentioned
SOLUTION
Answer: d
Explanation: All the following mentioned are decidability properties of a regular
language. The closure properties of a regular language include union, concatenation,
intersection, Kleene, complement , reverse and many more operations.

TOPIC 5: Equivalence and Minimization of Automata


1. Which of the following is same as the given DFA?

a) (0+1)*001(0+1)*
b) 1*001(0+1)*
c) (01)*(0+0+1)(01)*
d) None of the mentioned
SOLUTION
Answer: a
Explanation: There needs to be 001 together in the string as an essential substring.
Thus, the other components can be anything, 0 or 1 or e.
2. Which of the following statements is not true?
a) Every language defined by any of the automata is also defined by a regular
expression
b) Every language defined by a regular expression can be represented using a DFA
c) Every language defined by a regular expression can be represented using NFA with e
moves
d) Regular expression is just another representation for any automata definition
SOLUTION
Answer: b
Explanation: Using NFA with e moves, we can represent all the regular expressions
as an automata. As regular expressions include e, we need to use e moves.

30

Download Rejinpaul App from Playstore


www.rejinpaul.com

3. The total number of states required to automate the given regular expression
(00)*(11)*
a) 3
b) 4
c) 5
d) 6
SOLUTION
Answer: c

Explanation:
4. Which of the given regular expressions correspond to the automata shown?

31

Download Rejinpaul App from Playstore


www.rejinpaul.com

a) (110+1)*0
b) (11+110)*1
c) (110+11)*0
d) (1+110)*1
SOLUTION
Answer: c
Explanation: There is no state change for union operation, but has two different
paths while for concatenation or dot operation, we have a state change for every
element of the string.
5. Generate a regular expression for the following problem statement:
Password Validation: String should be 8-15 characters long. String must contain a
number, an Uppercase letter and a Lower case letter.
a) ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,15}$
b) ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{9,16}$
c) ^(?=.[a-z])(?=.[A-Z])(?=.\d).{8,15}$
d) None of the mentioned
SOLUTION
Answer: a
Explanation: Passwords like abc123, 123XYZ, should not be accepted . If one also
wants to include special characters as one of the constraint, one can use the
following regular expression:
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-za-Z]).{8,15}$

32

Download Rejinpaul App from Playstore


www.rejinpaul.com

6. Generate a regular expression for the following problem statement:


P(x): String of length 6 or less for å={0,1}*
a) (1+0+e)6
b) (10)6
c) (1+0)(1+0)(1+0)(1+0)(1+0)(1+0)
d) More than one of the mentioned is correct
SOLUTION
Answer: a
Explanation: As the input variables are under Kleene Operation, we need to include
e,thus option c is not correct,thereby option (a) is the right answer.
7. The minimum number of states required in a DFA (along with a dumping state) to
check whether the 3rd bit is 1 or not for |n|>=3
a) 3
b) 4
c) 5
d) 1
SOLUTION
Answer: c
Explanation:

8. Which of the regular expressions corresponds to the given problem statement:


P(x): Express the identifiers in C Programming language
l=letters
d=digits
a) (l+_)(d+_)*
b) (l+d+_)*
c) (l+_)(l+d+_)*
d) (_+d)(l+d+_)*
SOLUTION
Answer: c
Explanation: Identifiers in C Programming Language follows the following identifiers
rule:

33

Download Rejinpaul App from Playstore


www.rejinpaul.com

a) The name of the identifier should not begin with a digit.


b) It can only begin with a letter or a underscore.
c) It can be of length 1 or more.
9. Generate a regular expression for the given language:l
L(x): {xÎ{0,1}*| x ends with 1 nd does not contain a substring 01}
a) (0+01)*
b) (0+01)*1
c) (0+01)*(1+01)
d) All of the mentioned
SOLUTION
Answer: c
Explanation: (a) and (b) are the general cases where we restrict the acceptance of a
string witrh substring 00 but we ignore the case where the string needs to end with 1
which therby, does not allows the acceptance of e.
10. The minimum number of transitions to pass to reach the final state as per the
following regular expression is:
{a,b}*{baaa}
a) 4
b) 5
c) 6
d) 3
SOLUTION
Answer: a

Explanation:

34

Download Rejinpaul App from Playstore


www.rejinpaul.com

UNIT III CONTEXT FREE GRAMMAR AND LANGUAGES


TOPIC 1: CFG
1. The entity which generate Language is termed as:
a) Automata
b) Tokens
c) Grammar
d) Data
SOLUTION
Answer: c
Explanation: The entity which accepts a language is termed as Automata while the
one which generates it is called Grammar. Tokens are the smallest individual unit of a
program.
2. Production Rule: aAb->agb belongs to which of the following category?
a) Regular Language
b) Context free Language
c) Context Sensitive Language
d) Recursively Ennumerable Language
SOLUTION
Answer: c
Explanation: Context Sensitive Language or Type 1 or Linearly Bounded Non
deterministic Language has the production rule where the production is context
dependent i.e. aAb->agb.
3. Which of the following statement is false?
a) Context free language is the subset of context sensitive language
b) Regular language is the subset of context sensitive language
c) Recursively ennumerable language is the super set of regular language
d) Context sensitive language is a subset of context free language
SOLUTION
Answer: d
Explanation: Every regular language can be produced by context free grammar and
context free language can be produced by context sensitive grammar and so on.

4. The Grammar can be defined as: G=(V, ∑, p, S)


In the given definition, what does S represents?
a) Accepting State
b) Starting Variable
c) Sensitive Grammar

35

Download Rejinpaul App from Playstore


www.rejinpaul.com

d) None of these
SOLUTION
Answer: b
Explanation: G=(V, ∑, p, S), here V=Finite set of variables, ∑= set of terminals, p=
finite productions, S= Starting Variable.
5. Which among the following cannot be accepted by a regular grammar?
a) L is a set of numbers divisible by 2
b) L is a set of binary complement
c) L is a set of string with odd number of 0
d) L is a set of 0n1n
SOLUTION
Answer: d
Explanation: There exists no finite automata to accept the given language i.e. 0n1n.
For other options, it is possible to make a dfa or nfa representing the language set.
6. Which of the expression is appropriate?
For production p: a->b where a∈V and b∈
a) V
b) S
c) (V+∑)*
d) V+ ∑
SOLUTION
Answer: c
Explanation: According to the definition, the starting variable can produce another
variable or any terminal or a variable which leads to terminal.
7. For S->0S1|e for ∑={0,1}*, which of the following is wrong for the language
produced?
a) Non regular language
b) 0n1n | n>=0
c) 0n1n | n>=1
d) None of the mentioned
SOLUTION
Answer: d
Explanation: L={e, 01, 0011, 000111, ……0n1n }. As epsilon is a part of the set, thus all
the options are correct implying none of them to be wrong.
8. The minimum number of productions required to produce a language consisting of
palindrome strings over ∑={a,b} is
a) 3
b) 7
c) 5
d) 6
SOLUTION
Answer: c

36

Download Rejinpaul App from Playstore


www.rejinpaul.com

Explanation: The grammar which produces a palindrome set can be written as:
S-> aSa | bSb | e | a | b
L={e, a, b, aba, abbbaabbba…..}
9. Which of the following statement is correct?
a) All Regular grammar are context free but not vice versa
b) All context free grammar are regular grammar but not vice versa
c) Regular grammar and context free grammar are the same entity
d) None of the mentioned
SOLUTION
Answer: a
Explanation: Regular grammar is a subset of context free grammar and thus all
regular grammars are context free.
10. Are ambiguous grammar context free?
a) Yes
b) No
SOLUTION
Answer: a
Explanation: A context free grammar G is ambiguous if there is atleast one string in
L(G) which has two or more distinct leftmost derivations.

TOPIC 2: Parse Trees


1. The most suitable data structure used to represent the derivations in compiler:
a) Queue
b) Linked List
c) Tree
d) Hash Tables
SOLUTION
Answer: c
Explanation: The tree, known as “Parse tree” when used in a compiler, is the data
structure of choice to represent the source program.
2. Which of the following statement is false in context of tree terminology?
a) Root with no children is called a leaf
b) A node can have three children
c) Root has no parent
d) Trees are collection of nodes, with a parent child relationship
SOLUTION
Answer: a
Explanation: A node has atmost one parent, drawn above the node, and zero or more
children drawn below. Lines connect parents to children. There is one node, one root,
that has no parent; this node appears to be at the top of the tree. Nodes with no
children are called leaves. Nodes that are not leaves are called interior nodes.

37

Download Rejinpaul App from Playstore


www.rejinpaul.com

3. In which order are the children of any node ordered?


a) From the left
b) From the right
c) Arbitrarily
d) None of the mentioned
SOLUTION
Answer: a
Explanation: The children of a node are ordered from the left and drawn so. If N is to
the left of node M, then all the descendents of N are considered to be to the left of all
the descendents of M.
4. Which among the following is the root of the parse tree?
a) Production P
b) Terminal T
c) Variable V
d) Starting Variable S
SOLUTION
Answer: d
Explanation: The root is labelled by the start symbol. All the leaves are either
labelled by a a terminal or with e.
5. For the expression E*(E) where * and brackets are the operation, number of nodes in
the respective parse tree are:
a) 6
b) 7
c) 5
d) 2
SOLUTION
Answer: b

Explanation:
6. The number of leaves in a parse tree with expression E*(E) where * and () are
operators
a) 5
b) 2
c) 4
d) 3

38

Download Rejinpaul App from Playstore


www.rejinpaul.com

SOLUTION
Answer: a

Explanation:
7. Which of the following does the given parse tree correspond to?

a) P->1100
b) P->0110
c) P->1100ε
d) P->0101
SOLUTION
Answer: b
Explanation: The following is a parse tree for the production 0110 over {0,1}*.
8. A grammar with more than one parse tree is called:
a) Unambiguous
b) Ambiguous

39

Download Rejinpaul App from Playstore


www.rejinpaul.com

c) Regular
d) None of the mentioned
SOLUTION
Answer: b
Explanation: A context free grammar G is ambiguous if there is at least one string in
L(G) having two or more distinct derivation trees or equivalently, two or more
distinct leftmost derivations.
9. is the acyclic graphical representation of a grammar.
a) Binary tree
b) Oct tree
c) Parse tree
d) None of the mentioned
SOLUTION
Answer: c
Explanation: In order to graphically represent a derivation of a grammar we need to
use parse trees.
10. Grammar is checked by which component of compiler
a) Scanner
b) Parser
c) Semantic Analyzer
d) None of the mentioned
SOLUTION
Answer: Parser or syntax analyzer is the one responsible for checking the grammar
and reporting errors. In this phase, parse tree is generated and syntax is analyzed.
TOPIC 3: Ambiguity in Grammars and Languages
1. Which of the following is not a notion of Context free grammars?
a) Recursive Inference
b) Derivations
c) Sentential forms
d) All of the mentioned
SOLUTION
Answer: d
Explanation: The following are the notions to express Context free grammars:
a) Recursive Inferences
b) Derivations
c) Sentential form
d) Parse trees
2. State true or false:
Statement: The recursive inference procedure determines that string w is in the
language of the variable A, A being the starting variable.
a) true
b) false

40

Download Rejinpaul App from Playstore


www.rejinpaul.com

SOLUTION
Answer: a
Explanation: We apply the productions of CFG to infer that certain strings are in the
language of a certain variable.
3. Which of the following is/are the suitable approaches for inferencing?
a) Recursive Inference
b) Derivations
c) Both Recursive Inference and Derivations
d) None of the mentioned
SOLUTION
Answer: c
Explanation: Two inference approaches:
1. Recursive inference, using productions from body to head
2. Derivations, using productions from head to body
4. If w belongs to L(G), for some CFG, then w has a parse tree, which defines the
syntactic structure of w. w could be:
a) program
b) SQL-query
c) XML document
d) All of the mentioned
SOLUTION
Answer: d
Explanation: Parse trees are an alternative representation to derivations and
recursive inferences. There can be several parse trees for the same string.
5. Is the following statement correct?
Statement: Recursive inference and derivation are equivalent.
a) Yes
b) No
SOLUTION
Answer: a
Explanation: Yes, they are equivalent. Both the terminologies represent the two
approaches of recursive inferencing.
6. A->aA| a| b
The number of steps to form aab:
a) 2
b) 3
c) 4
d) 5
SOLUTION
Answer: b
Explanation: A->aA=>aaA=>aab
7. An expression is mentioned as follows. Figure out number of incorrect notations or

41

Download Rejinpaul App from Playstore


www.rejinpaul.com

symbols, such that a change in those could make the expression correct.
L(G)={w in T*|S→*w}
a) 0 Errors
b) 1 Error
c) 2 Error
d) Invalid Expression
SOLUTION
Answer: a
Explanation: For the given expression, L(G)={w in T*|S→*w}, If G(V, T, P, S) is a CFG,
the language of G, denoted by L(G), is the set of terminal strings that have
derivations from the start symbol.
8. The language accepted by Push down Automaton:
a) Recursive Language
b) Context free language
c) Linearly Bounded language
d) All of the mentioned
SOLUTION
Answer: b
Explanation: Push down automata accepts context free language.
9. Which among the following is the correct option for the given grammar?
G->X111|G1,X->X0|00
a) {0a1b|a=2,b=3}
b) {0a1b|a=1,b=5}
c) {0a1b|a=b}
d) More than one of the mentioned is correct
SOLUTION
Answer: a
Explanation: Using the recursive approach, we can conclude that option a is the
correct answer, and its not possible for a grammar to have more than one language.
10. Which of the following the given language belongs to?
L={ambmcm| m>=1}
a) Context free language
b) Regular language
c) Both (a) and (b)
d) None of the mentioned
SOLUTION
Answer: d
Explanation: The given language is neither accepted by a finite automata or a push
down automata. Thus, it is neither a context free language nor a regular language.
11. Choose the correct option:
Statement: There exists two inference approaches:
a) Recursive Inference

42

Download Rejinpaul App from Playstore


www.rejinpaul.com

b) Derivation
a) true
b) partially true
c) false
d) none of the mentioned
SOLUTION
Answer: a
Explanation: We apply the productions of a CFG to infer that certain strings are in a
language of certain variable.
12. Choose the correct option:
Statement 1: Recursive Inference, using productions from head to body.
Statement 2: Derivations, using productions from body to head.
a) Statement 1 is true and Statement 2 is true
b) Statement 1 and Statement 2, both are false
c) Statement 1 is true and Statement 2 is false
d) Statement 2 is true and Statement 1 is true
SOLUTION
Answer: b
Explanation: Both the statements are false. Recursive Inference, using productions
from body to head. Derivations, using productions from head to body.
13. Which of the following statements are correct for a concept called inherent
ambiguity in CFL?
a) Every CFG for L is ambiguous
b) Every CFG for L is unambiguous
c) Every CFG is also regular
d) None of the mentioned
SOLUTION
Answer: a
Explanation: A CFL L is said to be inherently ambiguous if every CFG for L is
ambiguous.
14. Which of the theorem defines the existence of Parikhs theorem?
a) Parikh’s theorem
b) Jacobi theorem
c) AF+BG theorem
d) None of the mentioned
SOLUTION
Answer: a
Explanation: Rohit Parikh in 1961 proved in his MIT research paper that some context
free language can only have ambiguous grammars.

TOPIC 4: Definition of the Pushdown Automata


1. The production of the form A->B , where A and B are non terminals is called

43

Download Rejinpaul App from Playstore


www.rejinpaul.com

a) Null production
b) Unit production
c) Greibach Normal Form
d) Chomsky Normal Form
SOLUTION
Answer: b
Explanation: A->ε is termed as Null production while A->B is termed as Unit
production.
2. Halting states are of two types. They are:
a) Accept and Reject
b) Reject and Allow
c) Start and Reject
d) None of the mentioned
SOLUTION
Answer: a
Explanation: Halting states are the new tuple members introduced in turing machine
and is of two types: Accept Halting State and Reject Halting State.
3. A push down automata can be represented as:
PDA= ε-NFA +[stack] State true or false:
a) true
b) false
SOLUTION
Answer: a
Explanation:

4. A pushdown automata can be defined as: (Q, ∑, G, q0, z0, A, d)


What does the symbol z0 represents?
a) an element of G
b) initial stack symbol
c) top stack alphabet
d) all of the mentioned
SOLUTION
Answer: d
Explanation: z0 is the initial stack symbol, is an element of G. Other symbols like d
represents the transition function of the machine.
5. Which of the following correctly recognize the symbol ‘|-‘ in context to PDA?
a) Moves
b) transition function

44

Download Rejinpaul App from Playstore


www.rejinpaul.com

c) or/not symbol
d) none of the mentioned
SOLUTION
Answer: a
Explanation: Using this notation, we can define moves and further acceptance of a
string by the machine.
6. Which among the following is true for the given statement?
Statement :If there are strings R and T in a language L so that R is prefix of T and R is
not equivalent to T.
a) No DPDA can accept L by empty stack
b) DPDA can accept L by an empty stack
c) L is regular
d) None of the mentioned
SOLUTION
Answer: a
Explanation: If M is a DPDA accepting L by an empty stsck, R and T are distinct
strings in L, and R is a prefix of T, then the sequence of moves M must make in order
to accept R leaves the stack empty, since R∈L. But then T cannot be accepted, since
M cant move with an empty stack.
7. Which of the following can be accepted by a DPDA?
a) The set of even length palindrome over {a,b}
b) The set of odd length palindrome over {a,b}
c) {xxc| where c stands for the complement,{0,1}}
d) None of the mentioned
SOLUTION
Answer: d
Explanation: Theorem: The language pal of palindromes over the alphabet {0,1}
cannot be accepted by any finite automaton , and it is therefore not regular.
8. For a counter automaton, with the symbols A and Z0, the string on the stack is
always in the form of
a) A
b) AnZ0, n>=0
c) Z0An, n>=0
d) None of the mentioned
SOLUTION
Answer: b
Explanation:The possible change in the stack contents is a change in the number of
A’s on the stack.
9. State true or false:
Statement: Counter Automaton can exist for the language L={0i1i|i>=0}
a) true
b) false

45

Download Rejinpaul App from Playstore


www.rejinpaul.com

SOLUTION
Answer: a
Explanation: The PDA works as follows. Instead of saving excess 0’s or 1’s on the
stack, we save *’s and use two different states to indicate which symbol there is
currently a surplus of. The state q0 is the initial state and the only accepting state.
10. Let ∑={0,1}* and the grammar G be:
S->ε
S->SS
S->0S1|1S0
State which of the following is true for the given
a) Language of all and only Balanced strings
b) It contains equal number of 0’s and 1’s
c) Ambiguous Grammar
d) All of the mentioned
SOLUTION
Answer: d
Explanation: A string is said to be balanced if it consist of equal number of 0’s and 1’s.

TOPIC 5: Languages of a Pushdown Automata


1. Context free grammar is called Type 2 grammar because of
hierarchy.
a) Greibach
b) Backus
c) Chomsky
d) None of the mentioned
SOLUTION
Answer: c
Explanation: Chomsky hierarchy decide four type of language :Type 3- Regular
Language, Type 2-Context free language, Type 1-Context Sensitive Language, Type
0- Unrestricted or Recursively Ennumerable language.
2. a→b
Restriction: Length of b must be atleast as much length of a.
Which of the following is correct for the given assertion?
a) Greibach Normal form
b) Context Sensitive Language
c) Chomsky Normal form
d) Recursively Ennumerable language
SOLUTION
Answer: b
Explanation: A context-sensitive grammar (CSG) is a formal grammar in which the
left-hand sides and right-hand sides of any production rules may be surrounded by a
context of terminal and non terminal symbols. Context-sensitive grammars are more

46

Download Rejinpaul App from Playstore


www.rejinpaul.com

general than context-free grammars, in the sense that there are some languages
that cannot be described by context-free grammars, but can be described by CSG.
3. From the definition of context free grammars,
G=(V, T, P, S)
What is the solution of VÇT?
a) Null
b) Not Null
c) Cannot be determined, depends on the language
d) None of the mentioned
SOLUTION
Answer: a
Explanation: V is the set of non terminal symbols while T is the st of terminal
symbols, their intersection would always be null.
4. If P is the production, for the given statement, state true or false.
P: V->(V∑T)* represents that the left hand side production rule has no right or left
context.
a) true
b) false
SOLUTION
Answer: a
Explanation: Here the production P is from the definition of Context free grammar
and thus, has no right or left context.
5. There exists a Context free grammar such that:
X->aX
Which among the following is correct with respect to the given assertion?
a) Left Recursive Grammar
b) Right Recursive Grammar
c) Non Recursive Grammar
d) None of the mentioned
SOLUTION
Answer: b
Explanation: The grammar with right recursive production is known as Right
recursive grammar. Right recursive production is of the form X->aX where a is a
terminal and X is a non terminal.
6. If the partial derivation tree contains the root as the starting variable, the form is
known as:
a) Chomsky hierarchy
b) Sentential form
c) Root form
d) None of the mentioned
SOLUTION
Answer: b

47

Download Rejinpaul App from Playstore


www.rejinpaul.com

Explanation: Example: For any grammar, productions be:


S->AB
A->aaA| ^
B->Bb| ^
The partial derivation tree can be drawn as:

Since it has the root as S, this can be said to be in sentential form.


7. Find a regular expression for a grammar which generates a language which states :
L contains a set of strings starting wth an a and ending with a b, with something in the
middle.
a) a(a*Ub*)b
b) a*(aUb)b*
c) a(a*b*)b
d) None of the mentioned
SOLUTION
Answer: a
Explanation: The grammar for the same language can be stated as :
(1) S → aMb
(2) M → A
(3) M → B
(4) A → e
(5) A → aA
(6) B → e
(7) B → bB
8. Which of the following is the correct representation of grammar for the given regular
expression?
a(aUb)*b
a) (1) S → aMb
(2) M → e
(3) M → aM
(4) M → bM
b) (1) S → aMb
(2) M → Mab
(3) M → aM
(4) M → bM

48

Download Rejinpaul App from Playstore


www.rejinpaul.com

c) (1) S → aMb
(2) M → e
(3) M → aMb
(4) M → bMa
d) None of the mentioned
SOLUTION
Answer: a
Explanation:
The basic idea of grammar formalisms is to capture the structure of string by
a) using special symbols to stand for substrings of a particular structure
b) using rules to specify how the substrings are combined to form new substrings.
9. A CFG consist of the following elements:
a) a set of terminal symbols
b) a set of non terminal symbols
c) a set of productions
d) all of the mentioned
SOLUTION
Answer: d
Explanation: A CFG consists of:
a) a set of terminals, which are characters of alphabets that appear in the string
generated by the grammar.
b) a set of non terminals, which are placeholders for patterns of terminal symbols
that can be generated by the nonterminal symbols.
c) a set of productions, which are set of rules to transit from one state to other
forming up the string
d) a start symbol, a special non terminal symbol that appears in the initial string
generated in the grammar.
10. A CFG for a program describing strings of letters with the word “main” somewhere
in the string:
a) -> m a i n
-> | epsilon
-> A | B | … | Z | a | b … | z
b) –> m a i n
–>
–> A | B | … | Z | a | b … | z
c) –> m a i n
–> | epsilon
–> A | B | … | Z | a | b … | z
d) None of the mentioned
SOLUTION
Answer: a
Explanation: None.

49

Download Rejinpaul App from Playstore


www.rejinpaul.com

TOPIC 6: Equivalence of Pushdown Automata and CFG, Deterministic Pushdown


Automata.
1. The transition a Push down automaton makes is additionally dependent upon the:
a) stack
b) input tape
c) terminals
d) none of the mentioned
SOLUTION
Answer: a
Explanation: A PDA is a finite machine which has an additional stack storage. Its
transitions are based not only on input and the correct state but also on the stack.
2. A PDA machine configuration (p, w, y) can be correctly represented as:
a) (current state, unprocessed input, stack content)
b) (unprocessed input, stack content, current state)
c) (current state, stack content, unprocessed input)
d) none of the mentioned
SOLUTION
Answer: a
Explanation: A machine configuration is an element of K×Σ*×Γ*.
(p,w,γ) = (current state, unprocessed input, stack content).
3. |-* is the closure of |-
a) symmetric and reflexive
b) transitive and reflexive
c) symmetric and transitive
d) none of the mentioned
SOLUTION
Answer: b
Explanation: A string w is accepted by a PDA if and only if (s,w, e) |-* (f, e, e)
4. With reference of a DPDA, which among the following do we perform from the start
state with an empty stack?
a) process the whole string
b) end in final state
c) end with an empty stack
d) all of the mentioned
SOLUTION
Answer: d
Explanation: The empty stack in the end is our requirement relative to finite state
automatons.
5. A DPDA is a PDA in which:
a) No state p has two outgoing transitions
b) More than one state can have two or more outgoing transitions
c) Atleast one state has more than one transitions

50

Download Rejinpaul App from Playstore


www.rejinpaul.com

d) None of the mentioned


SOLUTION
Answer: a
Explanation: A Deterministic Push Down Automata is a Push Down Automata in
which no state p has two or more transitions.
6. State true or false:
Statement: For every CFL, G, there exists a PDA M such that L(G) = L(M) and vice versa.
a) true
b) false
SOLUTION
Answer: a
Explanation: There exists two lemma’s such that:
a) Given a grammar G, construct the PDA and show the equivalence
b) Given a PDA, construct a grammar and show the equivalence
7. If the PDA does not stop on an accepting state and the stack is not empty, the string
is:
a) rejected
b) goes into loop forever
c) both (a) and (b)
d) none of the mentioned
SOLUTION
Answer: a
Explanation: To accept a string, PDA needs to halt at an accepting state and with a
stack empty, else it is called rejected. Given a PDA M, we can construct a PDA M’ that
accepts the same language as M, by both acceptance criteria.
8. A language accepted by Deterministic Push down automata is closed under which of
the following?
a) Complement
b) Union
c) Both (a) and (b)
d) None of the mentioned
SOLUTION
Answer: a
Explanation: Deterministic Context free languages(one accepted by PDA by final
state), are drastically different from the context free languages. For example they
are closed under complementation and not union.
9. Which of the following is a simulator for non deterministic automata?
a) JFLAP
b) Gedit
c) FAUTO
d) None of the mentioned
SOLUTION

51

Download Rejinpaul App from Playstore


www.rejinpaul.com

Answer: a
Explanation: JFLAP is a software for experimenting with formal topics including
NFA, NPDA, multi-tape turing machines and L-systems.
10. Finite-state acceptors for the nested words can be:
a) nested word automata
b) push down automata
c) ndfa
d) none of the mentioned
SOLUTION
Answer: a
Explanation: The linear encodings of languages accepted by finite nested word
automata gives the class of ‘visibly pushdown automata’.

UNIT IV PROPERTIES OF CONTEXT FREE LANGUAGES

TOPIC 1: Normal Forms for CFG


1. The format: A->aB refers to which of the following?
a) Chomsky Normal Form
b) Greibach Normal Form
c) Backus Naur Form
d) None of the mentioned
SOLUTION
Answer: b
Explanation: A context free grammar is in Greibach Normal Form if the right hand
sides of all the production rules start with a terminal, optionally followed by some
variables.
2. Which of the following does not have left recursions?
a) Chomsky Normal Form
b) Greibach Normal Form
c) Backus Naur Form
d) All of the mentioned
SOLUTION
Answer: b
Explanation: The normal form is of the format:
A->aB where the right hand side production tends to begin with a terminal symbo,
thus having no left recursions.
3. Every grammar in Chomsky Normal Form is:
a) regular
b) context sensitive
c) context free
d) all of the mentioned

52

Download Rejinpaul App from Playstore


www.rejinpaul.com

SOLUTION
Answer: c
Explanation: Conversely, every context frr grammar can be converted into Chomsky
Normal form and to other forms.
4. Which of the production rule can be accepted by Chomsky grammar?
a) A->BC
b) A->a
c) S->e
d) All of the mentioned
SOLUTION
Answer: d
Explanation: in CNF, the production rules are of the form:
A->BC
A-> a
S->e
5. Given grammar G:
(1) S->AS
(2) S->AAS
(3) A->SA
(4) A->aa
Which of the following productions denies the format of Chomsky Normal Form?
a) 2,4
b) 1,3
c) 1, 2, 3, 4
d) 2, 3, 4
SOLUTION
Answer: a
Explanation: The correct format: A->BC, A->a, X->e.
6. Which of the following grammars are in Chomsky Normal Form:
a) S->AB|BC|CD, A->0, B->1, C->2, D->3
b) S->AB, S->BCA|0|1|2|3
c) S->ABa, A->aab, B->Ac
d) All of the mentioned
SOLUTION
Answer: a
Explanation: We can eliminate the options on the basis of the format we are aware of:
A->BC, B->b and so on.
7. With reference to the process of conversion of a context free grammar to CNF, the
number of variables to be introduced for the terminals are:
S->ABa
A->aab
B->Ac

53

Download Rejinpaul App from Playstore


www.rejinpaul.com

a) 3
b) 4
c) 2
d) 5
SOLUTION
Answer: a
Explanation: According to the number of terminals present in the grammar, we need
the corresponding that number of terminal variables while conversion.
8. In which of the following, does the CNF conversion find its use?
a) CYK Algorithm
b) Bottom up parsing
c) Preprocessing step in some algorithms
d) All of the mentioned
SOLUTION
Answer: d
Explanation: Besides the theoretical significance of CNF, it conversion scheme is
helpful in algorithms as a preprocessing step, CYK algorithms and the bottom up
parsing of context free grammars.
9. Let G be a grammar. When the production in G satisfy certain restrictions, then G is
said to be in .
a) restricted form
b) parsed form
c) normal form
d) all of the mentioned
SOLUTION
Answer: c
Explanation: When the production in G satisfy certain restrictions, then G is said to
be in ‘normal form’.
10. Let G be a grammar: S->AB|e, A->a, B->b
Is the given grammar in CNF?
a) Yes
b) No
SOLUTION
Answer: a
Explanation: e is allowed in CNF only if the starting variable does not occur on the
right hand side of the derivation.
TOPIC 2: Pumping Lemma for CFL
1. Which of the following is called Bar-Hillel lemma?
a) Pumping lemma for regular language
b) Pumping lemma for context free languages
c) Pumping lemma for context sensitive languages
d) None of the mentioned

54

Download Rejinpaul App from Playstore


www.rejinpaul.com

SOLUTION
Answer: b
Explanation: In automata theory, the pumping lemma for context free languages,
also kmown as the Bar-Hillel lemma, represents a property of all context free
languages.
2. Which of the expressions correctly is an requirement of the pumping lemma for the
context free languages?
a) uvnwxny
b) uvnwnxny
c) uv2nwx2ny
d) All of the mentioned
SOLUTION
Answer: b
Explanation: Let L be a CFL. Then there is an integer n so that for any u that belong
to language L satisfying |t| >=n, there are strings u, v, w, x, y and z satisfying
t=uvwxy
|vx|>0
|vwx|<=n For any m>=0, uvnwxny ∈ L
3. Let L be a CFL. Then there is an integer n so that for any u that belong to language L
satisfying
|t|>=n, there are strings u, v, w, x, y and z satisfying
t=uvwxy.
Let p be the number of variables in CNF form of the context free grammar. The value of
n in terms of p :
a) 2p
b) 2p
c) 2p+1
d) p2
SOLUTION
Answer: c
Explanation: This inequation has been derived from derivation tree for t which must
have height at least p+2(It has more than 2p leaf nodes, and therefore its height is
>p+1).
4. Which of the following gives a positive result to the pumping lemma restrictions and
requirements?
a) {aibici|i>=0}
b) {0i1i|i>=0}
c) {ss|s∈{a,b}*}
d) None of the mentioned
SOLUTION
Answer: b
Explanation: A positive result to the pumping lemma shows that the language is a

55

Download Rejinpaul App from Playstore


www.rejinpaul.com

CFL and ist contradiction or negative result shows that the given language is not a
Context Free language.
5. Using pumping lemma, which of the following cannot be proved as ‘not a CFL’?
a) {aibici|i>=0}
b) {ss|s∈{a,b}*}
c) The set legal C programs
d) None of the mentioned
SOLUTION
Answer: d
Explanation: There are few rules in C that are context dependent. For example,
declaration of a variable before it can be used.
6. State true or false:
Statement: We cannot use Ogden’s lemma when pumping lemma fails.
a) true
b) false
SOLUTION
Answer: b
Explanation: Although the pumping lemma provides some information about v and x
that are pumped, it says little about the location of these substrings in the string t. It
can be used whenever the pumping lemma fails. Example: {apbqcrds|p=0 or q=r=s},
etc.
7. Which of the following cannot be filled in the blank below?
Statement: There are CFLs L1 nad L2 so that is not a CFL.
a) L1∩L2
b) L1′
c) L1*
d) None of the mentioned
SOLUTION
Answer: c
Explanation: A set of context free language is closed under the following operations:
a) Union
b) Concatenation
c) Kleene
8. The pumping lemma is often used to prove that a language is:
a) Context free
b) Not context free
c) Regular
d) None of the mentioned
SOLUTION
Answer: b
Explanation: The pumping lemma is often used to prove that a given language L is
non-context-free, by showing that arbitrarily long strings s are in L that cannot be

56

Download Rejinpaul App from Playstore


www.rejinpaul.com

“pumped” without producing strings outside L.


9. What is the pumping length of string of length x?
a) x+1
b) x
c) x-1
d) x2
SOLUTION
Answer: a
Explanation: There exists a property of all strings in the language that are of length
p, where p is the constant-called the pumping length .For a finite language L, p is
equal to the maximum string length in L plus 1.
10. Which of the following does not obey pumping lemma for context free languages ?
a) Finite languages
b) Context free languages
c) Unrestricted languages
d) None of the mentioned
SOLUTION
Answer: c
Explanation: Finite languages (which are regular hence context free ) obey pumping
lemma where as unrestricted languages like recursive languages do not obey
pumping lemma for context free languages.

TOPIC 3: Closure Properties of CFL


1. The context free languages are closed under:
a) Intersection
b) Complement
c) Kleene
d) None of the mentioned
SOLUTION
Answer: c
Explanation: Context free languages are closed under the following operation: union,
kleene and concatenation. For regular languages, we can add intersection and
complement to the list.
2. Given Grammar G1:
S->aSb
S->e
Grammar G2:
R->cRd
R->e
If L(G)=L(G1) U L(G2), the number of productions the new starting variable would have:
a) 2
b) 3

57

Download Rejinpaul App from Playstore


www.rejinpaul.com

c) 4
d) 1
SOLUTION
Answer: a
Explanation:
T->S|R
S->aSb
S->e
R->cRd
R->e
3. Context free languages are not closed under:
a) Intersection
b) Intersection with Regular Language
c) Complement
d) All of the mentioned
SOLUTION
Answer: d
Explanation: It is a theorem which states that, Context free languages are not closed
under operations like intersection and complement.
4. Which of the following is incorrect?
There exists algorithms to decide if:
a) String w is in CFL L
b) CFL L is empty
c) CFL L is infinite
d) All of the mentioned
SOLUTION
Answer: d
Explanation: These properties are termed as decision properties of a CFL and include
a set of problems like infiniteness problem, emptiness problem and membership
problem.
5. If the start symbol is one of those symbols which produce no terminal through any
sequence, the CFL is said to be
a) nullable
b) empty
c) eliminated
d) none of the mentioned
SOLUTION
Answer: b
Explanation: In the process of removing useless symbols, if the starting symbol is
also a part, the CFL can be then termed as empty; otherwise not.
6. Using the pumping constant n, If there is a string in the language of length between
and then the language is infite else not.

58

Download Rejinpaul App from Playstore


www.rejinpaul.com

a) n, 2n-1
b) 2n, n
c) n+1, 3n+6
d) 0, n+1
SOLUTION
Answer: a
Explanation: If there is a string in the language of length between n and 2n-1 then
the language is infite else not. The idea is essentially the same for regular languages.
7. Which of the following is/are CFL not closed under?
a) Reverse
b) Homomorphism
c) Inverse Homomorphism
d) All of the mentioned
SOLUTION
Answer: d
Explanation: CFL is closed under union, kleene and concatenation along with the
properties reversal,homomorphism and inverse homomorphism but not difference
and intersection.
8. If L1 and L2 are context free languages, L1-L2 are context free:
a) always
b) sometimes
c) never
d) none of the mentioned
SOLUTION
Answer: c
Explanation: Context free languages are not closed under difference, intersection
and complement operations.
9. A is context free grammar with atmost one non terminal in the right
handside of the production.
a) linear grammar
b) linear bounded grammar
c) regular grammar
d) none of the mentioned
SOLUTION
Answer: a
Explanation: A simple linear grammar is G with N = {S}, Σ = {a, b}, P with start
symbol S and rules
S → aSb
S →ε
10. There is a linear grammar that generates a context free grammar
a) always
b) never

59

Download Rejinpaul App from Playstore


www.rejinpaul.com

c) sometimes
d) none of the mentioned
SOLUTION
Answer: c
Explanation: Linear grammar is a subset of context free grammar which has atmost
one non terminal symbol in the right hand side of the production.Thus, there exists
some languages which are generated by Linear grammars.

TOPIC 4: Turing Machines


1. A turing machine is a
a) real machine
b) abstract machine
c) hypothetical machine
d) more than one option is correct
SOLUTION
Answer: d
Explanation: A turing machine is abstract or hypothetical machine thought by
mathematician Alan Turing in 1936 capable of simulating any algorithm, however
complicated it is.
2. A turing machine operates over:
a) finite memory tape
b) infinite memory tape
c) depends on the algorithm
d) none of the mentioned
SOLUTION
Answer: b
Explanation: The turing machine operates on an infinite memory tape divided into
cells. The machine positions its head over the cell and reads the symbol.
3. Which of the functions are not performed by the turing machine after reading a
symbol?
a) writes the symbol
b) moves the tape one cell left/right
c) proceeds with next instruction or halts
d) none of the mentioned
SOLUTION
Answer: d
Explanation: After the read head reads the symbol from the input tape, it performs
the following functions:
a) writes a symbol(some model allow symbol erasure/no writing)
b) moves the tape left or right (some models allows no motion)
c) proceeds with subsequent instruction or goes either into accepting halting state or
rejecting halting state.

60

Download Rejinpaul App from Playstore


www.rejinpaul.com

4. ‘a’ in a-machine is :
a) Alan
b) arbitrary
c) automatic
d) None of the mentioned
SOLUTION
Answer: c
Explanation: The turing machine was invented by Alan turing in 1936. He named it as
a-machine(automatic machine).
5. Which of the problems were not answered when the turing machine was invented?
a) Does a machine exists that can determine whether any arbitrary machine on its tape
is circular.
b) Does a machine exists that can determine whether any arbitrary machine on its tape
is ever prints a symbol
c) Hilbert Entscheidungs problem
d) None of the mentioned
SOLUTION
Answer: d
Explanation: Invention of turing machine answered a lot of questions which included
problems like decision problem, etc.) . Alan was able to prove the properties of
computation using such model.
6. The ability for a system of instructions to simulate a Turing Machine is called

a) Turing Completeness
b) Simulation
c) Turing Halting
d) None of the mentioned
SOLUTION
Answer: a
Explanation: Turing Completeness the ability for a system of instructions to simulate
a Turing machine. A programming language that is Turing complete is theoretically
capable of expressing all tasks accomplishable by computers; nearly all programming
languages are Turing complete.
7. Turing machine can be represented using the following tools:
a) Transition graph
b) Transition table
c) Queue and Input tape
d) All of the mentioned
SOLUTION
Answer: d
Explanation: We can represent a turing machine, graphically, tabularly and
diagramatically.

61

Download Rejinpaul App from Playstore


www.rejinpaul.com

8. Which of the following is false for an abstract machine?


a) Turing machine
b) theoretical model of computer
c) assumes a discrete time paradigm
d) all of the mentioned
SOLUTION
Answer: d
Explanation: A n abstract machine also known as abstract computer, is a theoretical
model of computer or hardware system in automata theory. Abstraction in
computing process usually assumes a discrete time paradigm.
9. Fill in the blank with the most appropriate option.
Statement: In theory of computation, abstract machines are often used in
regarding computability or to analyze the complexity of an algorithm.
a) thought experiments
b) principle
c) hypothesis
d) all of the mentioned
SOLUTION
Answer: d
Explanation: A thought experiment considers some hypothesis, theory or principle
for the purpose of thinking through its consequences.
10. State true or false:
Statement: RAM model allows random access to indexed memory locations.
a) true
b) false
SOLUTION
Answer: a
Explanation: In computer science, Random access machine is an abstract machine in
the general class of register machines. Random access machine should not be
confused with Random access memory.

TOPIC 5: Programming Techniques for TM.


This set of Automata Theory Multiple Choice Questions & Answers (MCQs) focuses on
“Programming Techniques-Storage and Subroutines”.
1. A turing machine has number of states in a CPU.
a) finite
b) infinte
c) May be finite
d) None of the mentioned
SOLUTION
Answer: a
Explanation: A turing machine has finite number of states in its CPU. However the

62

Download Rejinpaul App from Playstore


www.rejinpaul.com

states are not small in number. Real computer consist of registers which can store
values (fixed number of bits).
2. Suppose we have a simple computer with control unit holding a PC with a 32 bit
address + Arithmetic unit holding one double length 64 bit Arithmetic Register. The
number of states the finite machine will hold:
a) 2(32*64)
b) 296
c) 96
d) 32
SOLUTION
Answer: b
Explanation: According to the statistics of the question, we will have a finite machine
with 2^96 states.
3. In one move a turing machine will:

a) Change a state
b) Write a tape symbol in the cell scanned
c) Move the tape head left or right
d) All of the mentioned
SOLUTION
Answer: d
Explanation: A move of a turing machine is the function of the state of finite control
and the tape symbol just scanned.
4. State true or false:
Statement: We can use the finite control of turing machine to hold a finite amount of
data.
a) true
b) false
SOLUTION
Answer: a
Explanation:

63

Download Rejinpaul App from Playstore


www.rejinpaul.com

The finite control not only contains state q but also three data, A, B, C. The following
technique requires no extension to the Turing Machine model. Shaping states this
way allows to describe transitions in more systematic way and often to simplify the
strategy of the program.
5. Statement 1: Multitrack Turing machine.
Statement 2: Gamma is Cartesian product of a finite number of finite sets.
Which among the following is the correct option?
a) Statement 1 is the assertion and Statement 2 is the reason
b) Statement 1 is the reason and Statement 2 is the assertion
c) Statement 1 and Statement 2 are independent from each other
d) None of the mentioned
SOLUTION
Answer: a
Explanation: Cartesian product works like a struct in C/C++. For Example: Computer
tape storage is something like 8 or 9 bits in each cell. One can recognize a multi track
tape machine by looking at the transitions because each will have tuples as the read
and write symbols.
6. A multi track turing machine can described as a 6-tuple (Q, X, S, d, q0, F) where X
represents:
a) input alphabet
b) tape alphabet
c) shift symbols
d) none of the mentioned
SOLUTION
Answer: b
Explanation: The 6-tuple (Q, X, S, d, q0, F) can be explained as:
Q represents finite set of states,
X represents the tape alphabet,
S represents the input alphabet
d represents the relation on states and the symbols
q0 represents the initial state
F represents the set of final states.
7. Which of the following statements are false?
a) A multi track turing machine is a special kind of multi tape turing machine

64

Download Rejinpaul App from Playstore


www.rejinpaul.com

b) 4-heads move independently along 4-tracks in standard 4-tape turing machine


c) In a n-track turing machine, n head reads and writes on all the tracks simultaneously.
d) All of the mentioned
SOLUTION
Answer: c
Explanation: In a n-track turing machine, one head reads and writes on all the tracks
simultaneously.
8. State true or false:
Statement: Two track turing machine is equivalent to a standard turing machine.
a) true
b) false
SOLUTION
Answer: a
Explanation: This can be generalized for n- tracks and can be proved equivalent
using ennumerable languages.
9. Which of the following is/are not true for recursively ennumerable language?
a) partially decidable
b) Turing acceptable
c) Turing Recognizable
d) None of the mentioned
SOLUTION
Answer: d
Explanation: In automata theory, a formal language is called recursively
ennumerable language or partially decidable or semi decidable or turing acceptable
or turing recognizable if there exists a turing machine which will ennumerate all valid
strings of the language.
10. According to Chomsky hierarchy, which of the following is adopted by Recursively
Ennumerable language?
a) Type 0
b) Type 1
c) Type 2
d) Type 3
SOLUTION
Answer: a
Explanation: Recursively Ennumerable languages are type 0 languages in the
Chomsky hierarchy. All regular, context free, context sensitive languages are
recursivelyennumerable language.

65

Download Rejinpaul App from Playstore


www.rejinpaul.com

UNIT V UNDECIDABILITY

TOPIC 1: Non Recursive Enumerable (RE) Language


1. Which of the following technique is used to find whether a natural language isnt
recursive ennumerable?
a) Diagonalization
b) Recursive Induction
c) Both (a) and (b)
d) None of the mentioned
SOLUTION
Answer: a
Explanation: To find a non recursively ennumerable language, we use the technique
of diagonalization.
2. Diagonalization can be useful in:
a) To find a non recursively ennumerable language
b) To prove undecidablility of haltig problem
c) Both (a) and (b)
d) None of the mentioned
SOLUTION
Answer: c
Explanation: Diagonalization is a technique we use for the following operations:
a) To find a non recursively ennumerable language.
b) To prove undecidablility of halting problem.
3. Which of the following are undecidable problems?
a) Determining whether two grammars generate the same language
b) Determining whether a grammar is ambiguous
c) Both (a) and (b)
d) None of the mentioned
SOLUTION
Answer: c
Explanation: In contrast we can put up an algorithm for checking whether two FA’s
are equivalent and this program can be implemented as a program.
4. Which of the following are incorrect options?
a) Informally, problem is a yes/no question about an infinite set of possible instances
b) Formally, a problem is a language
c) Both (a) and (b)
d) None of the mentioned
SOLUTION
Answer: d
Explanation: Example: Does a graph G has a Hamilton cycle?
=>Each undirected graph is an instance of Hamilton cycle problem.
5. If a problem has an algorithm to answer it, we call it

66

Download Rejinpaul App from Playstore


www.rejinpaul.com

a) decidable
b) solved
c) recognizable
d) none of the mentioned
SOLUTION
Answer: a
Explanation: An algorithm is a TM that halts on all inputs,accepted or not. Putting
other way, decidable problems are recursive languages.
6. Which of the following are decidable problems?
a) Can a particular line of code in a program ever be executed?
b) Do two given CFG’s generate the same language
c) Is a given CFG ambiguous?
d) None of the mentioned
SOLUTION
Answer: d
Explanation: All of the mentioned problems are undecidable.
7. Which one of the following is true for the given?
A={(M,w)|M is a turing machine that accepts string w}
a) A concrete undecidable problem
b) A is recognizable but not decidable
c) -A is not recognizable
d) All of the mentioned
SOLUTION
Answer: d
Explanation: We can proof A to be undecidable using the contradiction method.
8. Which of the following are correct statements?
a) TMs that always halt are known as Decidable problems
b) TMs that are guaranteed to halt only on acceptance are recursive ennumerable.
c) Both (a) and (b)
d) None of the mentioned
SOLUTION
Answer: c
Explanation: There are two types of TMs on the basis of halting: Recursive and
Recursively Ennumerable(TM may or may not halt,could loop forever).
9. Statement: If L id R.E., Lc needs to be R.E. Is it correct?
a) Yes
b) No
c) Maybe
d) Cannot predict
SOLUTION
Answer: b
Explanation: Any recursive ennumerable language is not closed under

67

Download Rejinpaul App from Playstore


www.rejinpaul.com

complementation.
10. Which of the following is true for The Halting problem?
a) It is recursively ennumerable
b) It is undecidable
c) Both (a) and (b)
d) None of the mentioned
SOLUTION
Answer: c
Explanation: Halting problem: Does a given Turing machine M halt on a given input
w?
11. With reference to binary strings, state true or false:
Statement: For any turing machine, the input alphabet is restricted to {0,1}.
a) true
b) false
SOLUTION
Answer: a
Explanation: When turing machines are coded as Binary strings, we are restricted to
take any input alphabet except {0,1}.
12. With reference ti enumeration of binary strings, the conversion of binary strings to
integer is possible by treating the resulting string as a base integer.
a) 2
b) 8
c) 16
d) All of the mentioned
SOLUTION
Answer: a
Explanation: It makes sense to talk about the i-th binary string” and about “the i-th
Turing machine. If i makes no sense as a TM, assume the i-th TM accepts nothing.

TOPIC 2: Undecidable Problem with RE


1. The decision problem is the function from string to
a) char
b) int
c) boolean
d) none of the mentioned
SOLUTION
Answer: c
Explanation: The decision problem requires checking of input (string) has some
property or not. That is a string to boolean transaction.
2. A language L is said to be if there is a turing machine M such that
L(M)=L and M halts at every point.
a) Turing acceptable

68

Download Rejinpaul App from Playstore


www.rejinpaul.com

b) decidable
c) undecidable
d) none of the mentioned
SOLUTION
Answer: b
Explanation: Decidability refers to the decision problem and existence of a effective
method for determining membership, and return true and false accordingly rather
that going into a loop forever.
3. Which aong the following are undecidable theories?
a) The first order theory of boolean algebra
b) The first order theory of Euclidean geomentry
c) The first order theory of hyperbolic geometry
d) The first order theory of the natural number with addition, multiplication, and
equality
SOLUTION
Answer: d
Explanation: Tarski and Mostowski in 1949, established that the first order theory of
natural numbers with addition, multiplication, and equality is an undecidable theory.
Others mentioned are decidable theories.
4. Rec-DFA = { | M is a DFA and M recognizes input w}.
Fill in the blank:
Rec-DFA is
a) Undecidable
b) Decidable
c) Non finite
d) None of the mentioned
SOLUTION
Answer: b
Explanation: Under decidablity of regular language properties we have the following
lemma which states that A DFA which recognizes an input w is decidable.
5. Which among the following are semi decidable?
a) Empty-DFA
b) Rec-NFA
c) Infinite-DFA
d) All of the mentioned
SOLUTION
Answer: d
Explanation: All are the properties of regular languages and all are decidable
languages.
6. The language accepted by a turing machine is called
a) Recursive Ennumerable
b) Recursive

69

Download Rejinpaul App from Playstore


www.rejinpaul.com

c) Both (a) and (b)


d) None of the mentioned
SOLUTION
Answer: c
Explanation: The language accepted by Turing machines are called recursively
ennumerable (RE), and the subset of RE languages that are accepted by a turing
machine that always halts are called recursive.
7. Decidable can be taken as a synonym to:
a) recursive
b) non recursive
c) recognizable
d) none of the mentioned
SOLUTION
Answer: a
Explanation: We can refer to languages as ‘recursive’ and problems as ‘decidable’. If a
language is not recursive , then we call the problem expressed by that language
undecidable.
8. The problems which have no algorithm, regardless of whether or not they are
accepted by a turing machine that fails to halts on some input are referred as:
a) Decidable
b) Undecidable
c) Computable
d) None of the mentioned
SOLUTION
Answer: b
Explanation: The problems that can be solved by a turing machine can divided into
two classes:
a) Those that have an algorithm
b) Intractable problems: Those that are only solved by a turing machine that may run
forever on inputs they do not accept.
9. An algorithm is called efficient if it runs in time on a serial computer.
a) polynomial
b) non polynomial
c) logarithmic
d) none of the mentioned
SOLUTION
Answer: a
Explanation: Example: Runtimes of efficient algorithms
O(n), O(nlogn), O(n3log2n)
Runtimes of inefficient algorithms
O(2n), O(n!)
10. A problem is called if its has an efficient algorithm for itself.

70

Download Rejinpaul App from Playstore


www.rejinpaul.com

a) tractable
b) intractable
c) computational
d) none of the mentioned
SOLUTION
Answer: a
Explanation: A problem is called intractable iff there is an efficient (i.e. polynomial
time) algorithm that solves it. A problem is called intractable iff there exists no
efficient algorithm that solves it.
11. A formal language is recursive if :
a) a total turing machine exists
b) a turing machine that halts for every input
c) turing machine rejects if the input does not belong to the language
d) all of the mentioned
SOLUTION
Answer: d
Explanation: A formal language is called recursive if it is a recursive subset of the set
of all possible finite sequences over the alphabet of the language.
12. Recursive languages are also known as:
a) decidable
b) undecidable
c) sometimes decidable
d) none of the mentioned
SOLUTION
Answer: a
Explanation: A language is recursive if there exists a turing machine such that it
halts i.e. accepts if the input belongs to the language else rejects. It is better called
Turing decidable language.
13. The class of recursive language is known as:
a) R
b) RC
c) RL
d) All of the mentioned
SOLUTION
Answer: a
Explanation: R is the set of all recursive languages, a class of decision problems
solvable by turing machines. Although, R is also used for the class RP.
14. Which of the following was not a part of Chomsky hierarchy ?
a) Context sensitive grammar
b) Unrestricted grammar
c) Recursive grammar
d) None of the mentioned

71

Download Rejinpaul App from Playstore


www.rejinpaul.com

SOLUTION
Answer: c
Explanation: All recursive languages are recursively enumerable. All regular, context
free and context sensitive languages are recursive.

TOPIC 3: Undecidable Problems about T M


1. Which of the following regular expression resembles the given diagram?

a) {a}*{b}*{a,b}
b) {a,b}*{aba}
c) {a,b}*{bab}
d) {a,b}*{a}*{b}*
SOLUTION
Answer: b
Explanation: The given diagram is a transition graph for a turing machine which
accepts the language with the regular expression {a,b}*{aba}.
2. Construct a turing machine which accepts a string with ‘aba’ as its substring.

72

Download Rejinpaul App from Playstore


www.rejinpaul.com

a)

b)

c)

73

Download Rejinpaul App from Playstore


www.rejinpaul.com

d)
SOLUTION
Answer: c
Explanation: The language consist of strings with a substring ‘aba’ as fixed at its end
and the left part can be anything including epsilon. Thus the turing machine uses five
states to express the language excluding the rejection halting state which if allowed
can modify the graph as:

3. The number of states required to automate the last question i.e. {a,b}*{aba}{a,b}*
using finite automata:
a) 4
b) 3

74

Download Rejinpaul App from Playstore


www.rejinpaul.com

c) 5
d) 6
SOLUTION
Answer: a
Explanation: The finite automata can be represented as:

4. The machine accept the string by entering into hA or it can:


a) explicitly reject x by entering into hR
b) enter into an infinte loop
c) Both (a) and (b)
d) None of the mentioned
SOLUTION
Answer: c
Explanation: Three things can occur when a string is tested over a turing machine:
a) enter into accept halting state
b) enter into reject halting state
c) goes into loop forever
5. d(q,X)=(r,Y,D) where D cannot be:

a) L
b) R
c) S
d) None of the mentioned
SOLUTION
Answer: c
Explanation: D represents the direction in which automata moves forward as per the
queue which surely cannot be a starting variable.
6. Which of the following can accept even palindrome over {a,b}
a) Push down Automata
b) Turing machine
c) NDFA
d) All of the mentioned

75

Download Rejinpaul App from Playstore


www.rejinpaul.com

SOLUTION
Answer: c
Explanation: A language generating strings which are palindrome is not regular, thus
cannot b represented using a finite automaton.
7. Which of the functions can a turing machine not perform?
a) Copying a string
b) Deleting a symbol
c) Accepting a pal
d) Inserting a symbol
SOLUTION
Answer: d
Explanation: Different turing machines exist for operations like copying a string,
deleting a symbol, inserting a symbol and accepting palindromes.
8. If T1 and T2 are two turing machines. The composite can be represented using the
expression:
a) T1T2
b) T1 U T2
c) T1 X T2
d) None of the mentioned
SOLUTION
Answer: a
Explanation: If T1 and T2 are TMs, with disjoint sets of non halting states and
transition function d1 and d2, respectively, we write T1T2 to denote this composite
TM.
9. The following turing machine acts like:

a) Copies a string

76

Download Rejinpaul App from Playstore


www.rejinpaul.com

b) Delete a symbol
c) Insert a symbol
d) None of the mentioned
SOLUTION
Answer: b
Explanation: A turing machine does the deletion by changing the tape contents from
yaz to yz, where y belongs to (S U {#})*.
10. What does the following transition graph shows:

a) Copies a symbol
b) Reverses a string
c) Accepts a pal
d) None of the mentioned
SOLUTION
Answer: c
Explanation: The composite TM accepts the language of palindromes over {a, b} by
comparing the input string to its reverse and accepting if and only if the two are
equal.
TOPIC 4: Post‘s Correspondence Problem
1. According to the rice’s theorem, If P is a non trivial property, Lp is :
a) infinite
b) decidable
c) undecidable
d) none of the mentioned
SOLUTION
Answer: c
Explanation: Rice’s theorem states that ‘Any non trivial property about the language
recognized by a turing machine is undecidable’.
2. Fill in the blank with reference to Rice’s theorem.
For any non-trivial property of no general or effective method can decide

77

Download Rejinpaul App from Playstore


www.rejinpaul.com

whether an algorithm computes it with that property.


a) partial functions
b) piecewise functions
c) both (a) and (b)
d) none of the mentioned
SOLUTION
Answer: a
Explanation: A property of partial functions is called trivial if it holds for all partial
computable functions or for none, and an effective decision method is called general
if it decides correctly for every algorithm.
3. Which of the following is incorrect according to rice theorem?
Let S be a set of language hat is non trivial:
a) there exists a TM that recognizes the language in S
b) there exists a TM that recognizes the language not in S
c) both (a) and (b)
d) none of the mentioned
SOLUTION
Answer: c
Explanation: According to rice theorem, it is undecidable to determine whether the
language recognized by an arbitrary turing machine lies in S.
4. Which of the following set of computable functions are decidable?
a) The class of computable functions that are constant, and its complement
b) The class of indices for computable functions that are total
c) The class of indices for recursively enumerable sets that are cofinite
d) All of the mentioned
SOLUTION
Answer: d
Explanation: According to Rice’s theorem, if there exists atleast one computable
function in a particular class C of computable functions and another computable
function not in C then the problem deciding whether a particular program computes
a function in C is undecidable.
5. Which of the following statements are undecidable?
For a given Turing Machine M,
a) does M halt on an empty input tape
b) does M halt for anly inputs at all?
c) is L(M) regular? Context free? Turing decidable?
d) all of the mentioned
SOLUTION
Answer: d
Explanation: All of the following mentioned are immediate results of Rice’s theorem
and thus, undecidable.
6. Post Correspondence problem is

78

Download Rejinpaul App from Playstore


www.rejinpaul.com

a) decidable decision problem


b) undecidable decision problem
c) not a decision problem
d) none of the mentioned
SOLUTION
Answer: b
Explanation: Post Correspondence problem is an undecidable decision problem that
was introduced by Emil Post in 1946. Being simpler than halting problem, it can be
used in proofs of undecidability.
7. State true or false:
Statement: The difference between PCP and MPCP is that in MPCP, a solution is
required to start with the first string on each list.
a) true
b) false
SOLUTION
Answer: a
Explanation: The MPCP is : Given lists A and B of K strings ,say A = w1 ,w2, …wk and
B= x1, x2,…..xk does there exists a sequence of integers i1,i2,…ir such that
w1wi1wi2…..wir = x1xi1xi2…xir?
8. PCP stands for?
a) Post Correspondence Problem
b) Post Corresponding Problem
c) Pre Correspondence problem
d) None of the mentioned
SOLUTION
Answer: a
Explanation: PCP or Post Correspondence problem is an undecidable decision
problem.
9. Can a Modified PCP problem be reduced to PCP?
a) yes
b) no
SOLUTION
Answer: a
Explanation: Yes, it can be. There exists a theorem and as well as its proof which
supports the assertion.
10. Consider three decision problem A, B, C. A is decidable and B is not. Which of the
following is a correct option?
a) C is undecidable if C is reducible to B
b) C is undecidable if B is reducible to C
c) C is decidable if A is reducible to C
d) C is decidable if C is reducible to B’s complement.
SOLUTION

79

Download Rejinpaul App from Playstore


www.rejinpaul.com

Answer: b
Explanation: As B is undecidable and it can be reduced to C, C is also an undecidable
problem.
TOPIC 5.1: The Class P Problem
1. If the number of steps required to solve a problem is O(nk), then the problem is said
to be solved in:
a) non-polynomial time
b) polynomial time
c) infinite time
d) none of the mentioned
SOLUTION
Answer: b
Explanation: Most of the operations like addition, subtraction, etc as well as
computing functions including powers, square roots and logarithms can be
performed in polynomial time. In the given question, n is the complexity of the input
and k is some non negative integer.
2. The value of constants like p and e can be calculated in:
a) polynomial time
b) non-polynomial time
c) cannot be calculated
d) none of the mentioned
SOLUTION
Answer: a
Explanation: The value of such constants can be calculated using algorithms which
have time complexity in terms if O(nk) i.e polynomial time.
3. Which of the following cannot be solved using polynomial time?
a) Linear Programming
b) Greatest common divisor
c) Maximum matching
d) None of the mentioned
SOLUTION
Answer: d
Explanation: In graph theory, a matching or independent edge set in a graph G is a
set of edges without common vertices. Given a graph (V, E), a matching M in G is a set
of pairwise non adjacent edges i.e. no two edges share a common vertex.
4. The complexity class P consist of all the decision problems that can be solved by
using polynomial amount of computation time.
a) Push Down automata
b) DFA
c) NDFA
d) Deterministic Turing machine
SOLUTION

80

Download Rejinpaul App from Playstore


www.rejinpaul.com

Answer: d
Explanation: All the decision problems that can be solved using a Deterministic
turing machine using polynomial time to compute, all belong to the complexity class
P.
5. A generalization of P class can be:
a) PTIME
b) DTIME
c) NP
d) None of the mentioned
SOLUTION
Answer: c
Explanation: P is a specific case of NP class, which is the class of decidable problems
decidable by a non deterministic turing machine that runs in polynomial time.
6. Which of the following options are correct with reference to P-complete problems?
a) used for the problems which are difficult to solve in limited space
b) every problem in P can be reduced to it using proper reductions
c) complete problem for complexity class P
d) all of the mentioned
SOLUTION
Answer: d
Explanation:
The notion of P-complete decision problems is useful in the analysis of:
a) which problems are tough to parallelize effectively
b) which problems are difficult to solve in limited space
7. A problem X belongs to P complexity class if there exist algorithm to solve
that problem, such that the number of steps of the algorithms bounded by a polynomial
in n, where n is the length of the input.
a) 1
b) 2
c) 3
d) all of the mentioned
SOLUTION
Answer: d
Explanation: A problem X belongs to P complexity class if there exist atleast 1
algorithm to solve that problem, such that the number of steps of the algorithms
bounded by a polynomial in n, where n is the length of the input. Thus, all the options
are correct.
8. Which of the following is a P-complete type of problem?
a) Circuit Value problem
b) Linear programming
c) Context free grammar membership
d) All of the mentioned

81

Download Rejinpaul App from Playstore


www.rejinpaul.com

SOLUTION
Answer: d
Explanation: Given a context free grammar and a string, can the string be generated
by the grammar? Such problems fall in the category of P-complete.
9. State true or false?
Statement: Given a turing machine, an input for the machine, and a number T(unary),
does that machine halt on that input within the first T-steps?
The given problem is P-complete.
a) true
b) false
SOLUTION
Answer: a
Explanation: If we can parallelize a general simulation of a sequential computer, then
we will be able to parallelize any program that runs on that computer. If this problem
is in NC, then so every other problem in P.
10. In the above problem, if the input is binary, the class the problem belongs?
a) EXPSPACE
b) DLOGTIME
c) EXPTIME-complete
d) All of the mentioned
SOLUTION
Answer: c
Explanation: It is the set of all decision problems that have exponential run time i.e.
solvable by deterministic turing machine in O(2p(n)) time, where p(n) is a polynomial
function of n.
TOPIC 5.2: The Class NP Problem

1. What does NP stands for in complexity classes theory?


a) Non polynomial
b) Non-deterministic polynomial
c) Both (a) and (b)
d) None of the mentioned
SOLUTION
Answer: b
Explanation: NP is said to be one of the most fundamental complexity classes. NP is
an acronym for Non deterministic polynomial time.
2. The hardest of NP problems can be:
a) NP-complete
b) NP-hard
c) P
d) None of the mentioned
SOLUTION

82

Download Rejinpaul App from Playstore


www.rejinpaul.com

Answer: a
Explanation: NP class contains many important problems, the hardest of which is
NP-complete, whose solution is sufficient to deal with any other NP problem in
polynomial time.
3. Which of the following contains NP?
a) PSPACE
b) EXPSPACE
c) Both (a) and (b)
d) None of the mentioned
SOLUTION
Answer: c
Explanation: It is sufficient to construct a PSPACE machine that loops over all proof
strings and feeds each one to a polynomial time verifier. It is also contained in
EXPTIME, since the same algorithm operates in exponential time.
4. Travelling sales man problem belongs to which of the class?
a) P
b) NP
c) Linear
d) None of the mentioned
SOLUTION
Answer: b
Explanation: Travelling Salesman Problem: Given an input matrix of distances
between n cities, this problem is to determine if there is a route visiting all cities with
total distance less than k.
5. State true or false?
Statement: If a problem X is in NP and a polynomial time algorithm for X could also be
used to solve problem Y in polynomial time, then Y is also in NP.
a) true
b) false
SOLUTION
Answer: a
Explanation: This is just a commutative property of NP complexity class where a
problem is said to be in NP if it can be solved using an algorithm which was used to
solve another NP problem in polynomial amount of time.
6. A problem which is both and is said to be NP complete.
a) NP, P
b) NP, NP hard
c) P, P complete
d) None of the mentioned
SOLUTION
Answer: a
Explanation: A problem is said to be NP Hard if an algorithm for solving the problem

83

Download Rejinpaul App from Playstore


www.rejinpaul.com

can be translated from for solving any other problem. It is easier to show a problem
NP than showing it Np Hard.
7. Which of the following is incorrect for the given phrase
Phrase :’solvable by non deterministic algorithms in polynomial time’
a) NP Problems
b) During control flow, non deterministic algorithm may have more than one choice
c) If the choices that non deterministic algorithm makes are correct, the amount of
time it takes is bounded by polynomial time.
d) None of the mentioned
SOLUTION
Answer: d
Explanation: Primality testing is a simple example. To decide whether a number is
prime or not, one simply selects non deterministically a number checks whether
factors exist for the number or not.
8. In terms of NTIME, NP problems are the set of decision problems which can be solved
using a non deterministic machine in time.
a) O(n)
b) O(n1/2)
c) O(nk), k∈N
d) None of the mentioned
SOLUTION
Answer: c
Explanation: The complexity class NP can be defined in terms of NTIME as:
NP=O(nk) for k ∈N.
9. Which of the following can be used to define NP complexity class?
a) Verifier
b) Polynomial time
c) Both (a) and (b)
d) None of the mentioned
SOLUTION
Answer: c
Explanation: NP can be defined using deterministic turing machines as verifiers.
10. Which of the following are not in NP?
a) All problems in P
b) Boolean Satisfiability problems
c) Integer factorization problem
d) None of the mentioned
SOLUTION
Answer: d
Explanation: This is a list of some problems which are in NP:
a) All problems in P
b) Decision version of Integer factorization method

84

Download Rejinpaul App from Playstore


www.rejinpaul.com

c) Graph Isomorphism Problem


d) All NP complete problems, etc.
11. Which of the following does not belong to the closure properties of NP class?
a) Union
b) Concatenation
c) Reversal
d) Complement
SOLUTION
Answer: d
Explanation: It is unknown about the closure property-complement for the
complexity class NP. The question is so called NP versus co-NP problem.

~OoO~

85

Download Rejinpaul App from Playstore

You might also like