TOC MCQs
TOC MCQs
com
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.
Answer: d
Explanation: It is possible to represent a finite automaton graphically, with nodes for
states, and arcs for transitions.
Answer: b
Explanation: According to the question, minimum of 3 states are required to recognize
an octal number divisible by 3.
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).
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.
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
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
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 .
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?
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
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.
11
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
13
14
15
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
f) Kleene closure
17
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?
18
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.
19
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
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
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.
22
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
24
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.
25
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
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?
27
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
29
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.
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
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
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
33
Explanation:
34
35
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
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.
37
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
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
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
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
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
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.
43
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:
44
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
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.
46
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
48
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
50
51
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’.
52
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
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
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
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
57
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
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
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.
60
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
62
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
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
65
UNIT V UNDECIDABILITY
66
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
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.
68
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
70
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
SOLUTION
Answer: c
Explanation: All recursive languages are recursively enumerable. All regular, context
free and context sensitive languages are recursive.
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
a)
b)
c)
73
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
c) 5
d) 6
SOLUTION
Answer: a
Explanation: The finite automata can be represented as:
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
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
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
78
79
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
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
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
82
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
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
~OoO~
85