TCS Mcqs
TCS Mcqs
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: 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: ∑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.
17. Which of the following will not be accepted by the following DFA?
a) ababaabaa
b) abbbaa
c) abbbaabb
d) abbaabbaa
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.
18. Which of the following will the given DFA won’t accept?
a) ε
b) 11010
c) 10001010
d) String of letter count 11
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.
20. 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
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.
Answer: a
Explanation: Construct the DFA and NFA individually, and the attain the difference of states.
23. An automaton that presents output based on previous state or current input:
a) Acceptor
b) Classifier
c) Transducer
d) None of the mentioned.
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.
24. 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
Answer: c
Explanation: The maximum number of sets for DFA converted from NFA would be not
greater than 2n.
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).
27. 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.
Answer: a
Explanation: The individual Transition graphs can be made and the difference of transitions
can be determined.
28. 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)
Answer: b
Explanation: From the coded NFA-DFA conversion.
29. 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
Answer: a
Explanation: Running time of DFA: O(n) and Running time of NFA =O(m2n).
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.
Answer: b
Explanation: Finite automaton with an output is categorize din two parts: Moore M/C and
Mealy M/C.
Answer: b
Explanation: Moore machine produces an output over the change of transition states while
mealy machine does it so for transitions itself.
33. For a give Moore Machine, Given Input=’101010’, thus the output would be of
length:
a) |Input|+1
b) |Input|
c) |Input-1|
d) Cannot be predicted
Answer: a
Explanation: Initial state, from which the operations begin is also initialized with a value.
Answer: a
Explanation: Even ε, when passed as an input to Moore machine produces an output.
35. The total number of states and transitions required to form a moore machine that
will produce residue mod 3.
a) 3 and 6
b) 3 and 5
c) 2 and 4
d) 2 and 5
Answer: a
Explanation:
36. Complete the given table according to the given Moore machine.
Present State
Next State
Output
0
1
Q0
Q1
Q2
1
Q1
Q2
1
Q2
Q0
a) Q0, Q2, 0
b) Q0, Q2, 1
c) Q1, Q2, 1
d) Q1, Q0, 0
Answer: a
Explanation: The table can be filled accordingly seeing the graph.
Answer: a
Explanation: The outputs are as per the input, produced.
Answer: b
Explanation: Source-The tuple definition of Moore and mealy machine comprises one new
member i.e. output alphabet as these are finite machines with output.
39. The O/P of Moore machine can be represented in the following format:
a) Op(t)=δ(Op(t))
b) Op(t)=δ(Op(t)i(t))
c) Op(t): ∑
d) None of the mentioned
Answer: a
Explanation: Op(t)=δ(Op(t)) is the defined definition of how the output is received on giving
a specific input to Moore machine.
40. Which of the following is a correct statement?
a) Moore machine has no accepting states
b) Mealy machine has accepting states
c) We can convert Mealy to Moore but not vice versa
d) All of the mentioned
Answer: a
Explanation: Statement a and b is correct while c is false. Finite machines with output have
no accepting states and can be converted within each other.
Answer: c
Explanation: Definition of Mealy Machine.
Answer: c
Explanation: Finite Automaton with Output has a common definition for both the categories.
a) 9’s Complement
b) 2’s Complement
c) 1’s Complement
d) 10’s Complement
Answer: b
Explanation: The input can be taken in form of a binary string and can be verified.
44. The O/P of Mealy machine can be represented in the following format:
a) Op(t)= δ(Op(t))
b) Op(t)= δ(Op(t)i(t))
c) Op(t): ∑
d) None of the mentioned
Answer: b
Explanation: The output of mealy machine depends on the present state as well as the input
to that state.
45.The ratio of number of input to the number of output in a mealy machine can be
given as:
a) 1
b) n: n+1
c) n+1: n
d) None of the mentioned
Answer: a
Explanation: The number of output here follows the transitions in place of states as in
Moore machine.
Answer: b
Explanation: They are collectively known as Transducers.
47. The major difference between Mealy and Moore machine is about:
a) Output Variations
b) Input Variations
c) Both
d) None of the mentioned
Answer: a
Explanation: Mealy and Moore machine vary over how the outputs depends on prior one
(transitions) and on the latter one(states).
Answer: a
Explanation: Being an input dependent and output capable FSM, Mealy machine reacts
faster to inputs.
49. Which of the following does the given Mealy machine represents?
a) 9’s Complement
b) 2’s Complement
c) 1’s Complement
d) 10’s Complement
Answer: c
Explanation: Inputs can be taken and can be verified.
50. Which one among the following is true?
A mealy machine
a) produces a language
b) produces a grammar
c) can be converted to NFA
d) has less circuit delays
Answer: d
Explanation: It does not produce a language or a grammar or can be converted to a NFA
Answer: d
Explanation: NFA is said to be closed under the following operations:
a) Union
b) Intersection
c) Concatenation
d) Kleene
e) Negation
52. It is less complex to prove the closure properties over regular languages using
a) NFA
b) DFA
c) PDA
d) Can’t be said
Answer: a
Explanation: We use the construction method to prove the validity of closure properties of
regular languages. Thus, it can be observe, how tedious and complex is the construction of a
DFA as compared to an NFA with respect to space.
Answer: d
Explanation: There are many applications of finite automata, mainly in the field of Compiler
Design and Parsers and Search Engines.
54. John is asked to make an automaton which accepts a given string for all the
occurrence of ‘1001’ in it. How many number of transitions would John use such that,
the string processing application works?
a) 9
b) 11
c) 12
d) 15
Answer: a
Explanation:
55. Which of the following do we use to form an NFA from a regular expression?
a) Subset Construction Method
b) Power Set Construction Method
c) Thompson Construction Method
d) Scott Construction Method
Answer: c
Explanation: Thompson Construction method is used to turn a regular expression in an NFA
by fragmenting the given regular expression through the operations performed on the input
alphabets.
56. Which among the following can be an example of application of finite state
machine(FSM)?
a) Communication Link
b) Adder
c) Stack
d) None of the mentioned
Answer: a
Explanation: Idle is the state when data in form of packets is send and returns if NAK is
received else waits for the NAK to be received.
Answer: d
Explanation: Finite state automation is used in Lexical Analyser, Computer BOT (used in
games), State charts, etc.
59. Predict the number of transitions required to automate the following language
using only 3 states:
L= {w | w ends with 00}
a) 3
b) 2
c) 4
d) Cannot be said
Answer: a
Explanation:
60. The total number of states to build the given language using DFA:
L= {w | w has exactly 2 a’s and at least 2 b’s}
a) 10
b) 11
c) 12
d) 13
Answer: a
Explanation: We need to make the number of a as fixed i.e. 2 and b can be 2 or more. Thus,
using this condition a finite automata can be created using 1 states.
61. Given Language: {x | it is divisible by 3}
The total number of final states to be assumed in order to pass the number
constituting {0, 1} is
a) 0
b) 1
c) 2
d) 3
Answer: c
Explanation: The DFA for the given language can be constructed as follows:
Answer: a
Explanation: If the string is divisible by four, it surely ends with the substring ‘100’ while a
binary string divisible by 2 would surely end with the substring ‘10’.
63. Let L be a language whose FA consist of 5 acceptance states and 11 non final
states. It further consists of a dumping state. Predict the number of acceptance states
in Lc.
a) 16
b) 11
c) 5
d) 6
Answer: a
Explanation: If L leads to FA1, then for Lc, the FA can be obtained by exchanging the final
and non-final states.
64. If L1 and L2 are regular languages, which among the following is an exception?
a) L1 U L2
b) L1 – L2
c) L1 ∩ L2
d) All of the mentioned
Answer: d
Explanation: It the closure property of Regular language which lays down the following
statement:
If L1, L2 are 2- regular languages, then L1 U L2, L1 ∩ L2, L1C, L1 – L2 are regular language.
Answer: a
Explanation: When set operation ‘-‘ is performed between two sets, it points to those values
of prior set which belongs to it but not to the latter set analogous to basic subtraction
operation.
66. Which among the following NFA’s is correct corresponding to the given
Language?
L= {xϵ {0, 1} | 3rd bit from right is 0}
a)
b)
c)
d) None of the mentioned
Answer: a
Explanation: The NFA accepts all binary strings such that the third bit from right end is 1 and
if not, is send to Dumping state. Note: It is assumed that the input is given from the right
end bit by bit.
67. Statement 1: NFA computes the string along parallel paths.
Statement 2: An input can be accepted at more than one place in an NFA.
Which among the following options are most appropriate?
a) Statement 1 is true while 2 is not
b) Statement 1 is false while is not
c) Statement 1 and 2, both are true
d) Statement 1 and 2, both are false
Answer: c
Explanation: While the machine runs on some input string, if it has the choice to split, it
goes in all possible way and each one is different copy of the machine. The machine takes
subsequent choice to split further giving rise to more copies of the machine getting each
copy run parallel. If any one copy of the machine accepts the strings, then NFA accepts,
otherwise it rejects.
68. Which of the following options is correct for the given statement?
Statement: If K is the number of states in NFA, the DFA simulating the same language
would have states less than 2k.
a) True
b) False
Answer: a
Explanation: If K is the number of states in NFA, the DFA simulating the same language
would have states equal to or less than 2k.
69. Let N (Q, ∑, δ, q0, A) be the NFA recognizing a language L. Then for a DFA (Q’, ∑,
δ’, q0’, A’), which among the following is true?
a) Q’ = P(Q)
b) Δ’ = δ’ (R, a) = {q ϵ Q | q ϵ δ (r, a), for some r ϵ R}
c) Q’={q0}
d) All of the mentioned
Answer: d
Explanation: All the optioned mentioned are the instruction formats of how to convert a
NFA to a DFA.
70. There exists an initial state, 17 transition states, 7 final states and one dumping
state, Predict the maximum number of states in its equivalent DFA?
a) 226
b) 224
c) 225
d) 223
Answer: a
Explanation: The maximum number of states an equivalent DFA can comprise for its
respective NFA with k states will be 2k.
Module 02
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
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
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.
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
c) (01)4
d) (0+1+ε)4
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.
Answer: a
Explanation: The given regular expression corresponds to a language of binary strings which
is of even length including a length of 0.
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.
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:
a) Union
b) Dot
c) Kleene
d) Two of the options are correct
Answer: b
Explanation: Two operands are said to be performing Concatenation operation AB = A•B =
{xy: x ∈ A & y ∈ B}.
Answer: b
Explanation: By distributive property (Regular expression identities), we can prove the given
identity to be Ф.
Answer: a
Explanation: RR*=R+ as R+ means the occurrence to be at least once.
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.
12. 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
Answer: d
Explanation: Regexp processors are found in several search engines, seach and replace
mechanisms, and text processing utilities.
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.
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.
Answer: a
Explanation: Paranthesis can be used to define the scope and precedence of operators.
Thus, both the expression represents the same pattern.
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
implementations.
17. 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
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.
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.
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’
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.
21. A regular language over an alphabet a is one that can be obtained from
a) union
b) concatenation
c) kleene
d) All of the mentioned
Answer: d
Explanation: None.
Answer: a
Explanation: None.
Answer: a
Explanation: None.
25. a? is equivalent to
a) a
b) a+Φ
c) a+ϵ
d) wrong expression
Answer: c
Explanation: Zero or one time repetition of previous character .
26. ϵL is equivalent to
a) ϵ
b) Φ
c) L
d) Lϵ
Answer: c,d
Explanation: None.
Answer: b
Explanation: None.
28. ΦL is equivalent to
a) LΦ
b) Φ
c) L
d) ϵ
Answer: a,b
Explanation: None.
29. Which of the following pair of regular expression are not equivalent?
a) 1(01)* and (10)*1
b) x(xx)* and (xx)*x
c) (ab)* and a*b*
d) x+ and x*x+
Answer: c
Explanation: (ab)*=(a*b*)*.
Answer: d
Explanation: All are equivalent to (a+b)*.
31. 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
c) decidable
d) none of the mentioned
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.
32. 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
Answer: d
Explanation: At first stage 1/2 L will be regular and subsequently, all the options will be
regular.
33. 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
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.
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.
Answer: a
Explanation: If A and B are regular languages, then A Ç B is a regular language and A ∩ B is
equivalent to !(A’ U B’).
36. 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
Answer: d
Explanation: Regular languages are closed under the following operations:
a) Regular expression operations
b) Boolean operations
c) Homomorphism
d) Inverse Homomorphism
37. 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
Answer: 4
Explanation: M is defined as: (Q, S, d, q0, F)
where Q=Q1*Q2 and F=F1*F2
Answer: a
Explanation: (L’)’ is equivalent to L and L U L is subsequently equivalent to L.
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.
40. Which among the following is the closure property of a regular language?
a) Emptiness
b) Universality
c) Membership
d) None of the mentioned
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.
41. 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
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.
42. 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
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.
43. 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
View Answer
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.
44. 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
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.
45. 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
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.
46. 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
Answer: b
Explanation: Finite languages trivially satisfy the pumping lemma by having n equal to the
maximum string length in l plus 1.
47. 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
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.
48. If d is a final state, which of the following is correct according to the given
diagram?
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.
49. 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
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.
50. 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
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.
Module 03
1. The entity which generate Language is termed as:
a) Automata
b) Tokens
c) Grammar
d) Data
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
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
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.
Explanation:
40. The number of leaves in a parse tree with expression E*(E) where * and () are
operators
a) 5
b) 2
c) 4
d) 3
Answer: a
Explanation:
41. Which of the following does the given parse tree correspond to?
a) P->1100
b) P->0110
c) P->1100ε
d) P->0101
Answer: b
Explanation: The following is a parse tree for the production 0110 over {0,1}*.
42. A grammar with more than one parse tree is called:
a) Unambiguous
b) Ambiguous
c) Regular
d) None of the mentioned
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.
43. __________ is the acyclic graphical representation of a grammar.
a) Binary tree
b) Oct tree
c) Parse tree
d) None of the mentioned
Answer: c
Explanation: In order to graphically represent a derivation of a grammar we need to use
parse trees.
44. Grammar is checked by which component of compiler
a) Scanner
b) Parser
c) Semantic Analyzer
d) None of the mentioned
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.
45. To derive a string using the production rules of a given grammar, we use:
a) Scanning
b) Parsing
c) Derivation
d) All of the mentioned
Answer: b
Explanation: Parsing is required to check the acceptability of a string. Further, comes the
syntactical phase which is taken care by other phases of compiler.
46. Which of the following parser reaches the root symbol of the tree at last?
a) Top down parser
b) Bottom up parser
c) TOP down and Bottom up parser
d) None of the mentioned
Answer: b
Explanation: Bottom up parser starts from the bottom with the string and comes up to the
start symbolusing a parse tree or a derivation tree.
47. Left corner parsing methof uses which of the following?
a) Top down parser
b) Bottom up parser
c) TOP down and Bottom up parser
d) None of the mentioned
Answer: c
Explanation: It is a hybrid method which works bottom up along the left edges of each
subtree, and top down on the rest of the parse tree.
48. Which of the following parser performs top down parsing?
a) LALR parser
b) LL parser
c) Recursive Accent parser
d) None of the mentioned
Answer: b
Explanation: Bottom up parsing is done by shift reduce parsers like LALR parsers, Operator
precedence parsers, simple precedence parsers, etc.
49. Which of the following is true for shift reduce parsers?
a) Scans and parses the input in one forward pass over the text, without any backup.
b) A shift command advances in the input stream by one symbol
c) LALR parser
d) All of the mentioned
Answer: d
Explanation: The mentioned are the correct and proper functions of a shift reduce parsers.
The parsing methods are most commonly used for parsing programming languages, etc.
50. State true or false:
Statement: LALR parsers uses tables rather than mutually recursive functions.
a) true
b) false
Answer: b
Explanation: It is exactly the opposite case where LALR parsers uses mutually recursive
functions instead of tables. It is a simplified version of canonical left to right parser.
51. LALR in LALR parser stands for:
a) Left aligned left right parser
b) Look ahead left to right parser
c) Language Argument left to right parser
d) None of the mentioned
Answer:
Explanation: LALR stands for Look ahead left to right parsers. It has more language
recognition power than LR(0) parser.
52. Which of the following can be a LALR parser generator?
a) YACC
b) GNU Bison
c) YACC and GNU Bison
d) None of the mentioned
Answer: c
Explanation: YACC is a computer code for UNIX operating system which generates a LALR
parser. On the other hand GNU Bison or Bison can generate LALR and GLR parsers.
53. Which of the following parsers do not relate to Bottom up parsing?
a) LL parser
b) Recursive descent parser
c) Earley parsers
d) All of the mentioned
Answer: d
Explanation: All the following mentioned are top down parsers and begin their operation
from the starting symbol.
54. Which of the following is true for a predictive parser?
a) Recursive Descent parser
b) no backtracking
c) Recursive Descent parser and no backtracking
d) None of the mentioned
Answer: c
Explanation: Predictive parsing is possible only for the class of LL-grammars, which are the
CFG for which there exists some positive integer k that allows a recursive descent parser to
decide which production to use by examining only the next k tokens of input.
55. 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
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.
56. 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
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.
57. Every grammar in Chomsky Normal Form is:
a) regular
b) context sensitive
c) context free
d) all of the mentioned
Answer: c
Explanation: Conversely, every context frr grammar can be converted into Chomsky Normal
form and to other forms.
58. 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
Answer: d
Explanation: in CNF, the production rules are of the form:
A->BC
A-> a
S->e
59. 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
Answer: a
Explanation: The correct format: A->BC, A->a, X->e.
60. 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
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.
61. 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
a) 3
b) 4
c) 2
d) 5
Answer: a
Explanation: According to the number of terminals present in the grammar, we need the
corresponding that number of terminal variables while conversion.
62. 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
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.
63. 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
Answer: c
Explanation: When the production in G satisfy certain restrictions, then G is said to be in
‘normal form’.
64. Let G be a grammar: S->AB|e, A->a, B->b
Is the given grammar in CNF?
a) Yes
b) No
Answer: a
Explanation: e is allowed in CNF only if the starting variable does not occur on the right
hand side of the derivation.
65. 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
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.
66. 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
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
67.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
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).
68. 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
Answer: b
Explanation: A positive result to the pumping lemma shows that the language is a CFL and
ist contradiction or negative result shows that the given language is not a Context Free
language.
69. 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
Answer: d
Explanation: There are few rules in C that are context dependent. For example, declaration
of a variable before it can be used.
70. State true or false:
Statement: We cannot use Ogden’s lemma when pumping lemma fails.
a) true
b) false
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.
71. 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
Answer: c
Explanation: A set of context free language is closed under the following operations:
a) Union
b) Concatenation
c) Kleene
72. 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
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 “pumped”
without producing strings outside L.
73. What is the pumping length of string of length x?
a) x+1
b) x
c) x-1
d) x2
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.
74. 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
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.
Module 04
1. The production of the form A->B , where A and B are non terminals is called
a) Null production
b) Unit production
c) Greibach Normal Form
d) Chomsky Normal Form
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
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
Answer: a
Explanation:
Answer: b
Explanation: Finite automaton with an output is categorize din two parts: Moore M/C
and Mealy M/C.
2. In Moore machine, output is produced over the change of:
a) transitions
b) states
c) Both
d) None of the mentioned
Answer: b
Explanation: Moore machine produces an output over the change of transition states
while mealy machine does it so for transitions itself.
3. Statement 1: Null string is accepted in Moore Machine.
Statement 2: There are more than 5-Tuples in the definition of Moore Machine.
Answer: a
Explanation: Even ε, when passed as an input to Moore machine produces an output.
4. What is the output for the given language?
Language: A set of strings over ∑= {a, b} is taken as input and it prints 1 as an output
“for every occurrence of a, b as its substring. (INPUT: abaaab)
a) 0010001
b) 0101010
c) 0111010
d) 0010000
Answer: a
Explanation: The outputs are as per the input, produced.
5. Which of the following is a correct statement?
a) Moore machine has no accepting states
b) Mealy machine has accepting states
c) We can convert Mealy to Moore but not vice versa
d) All of the mentioned
Answer: a
Explanation: Statement a and b is correct while c is false. Finite machines with output
have no accepting states and can be converted within each other.
6. 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.
7. 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.
8. 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).
9. 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
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.
10. In mealy machine, the O/P depends upon?
a) State
b) Previous State
c) State and Input
d) Only Input
Answer: c
Explanation: Definition of Mealy Machine.
11. Which of the given are correct?
a) Moore machine has 6-tuples
b) Mealy machine has 6-tuples
c) Both Mealy and Moore has 6-tuples
d) None of the mentioned
Answer: c
Explanation: Finite Automaton with Output has a common definition for both the
categories.
12. The major difference between Mealy and Moore machine is about:
a) Output Variations
b) Input Variations
c) Both
d) None of the mentioned
Answer: a
Explanation: Mealy and Moore machine vary over how the outputs depends on prior
one (transitions) and on the latter one(states).
13. Which one among the following is true?
A mealy machine
a) produces a language
b) produces a grammar
c) can be converted to NFA
d) has less circuit delays
Answer: d
Explanation: It does not produce a language or a grammar or can be converted to a
NFA.
14. Given:
L= {xϵ∑= {0,1} |x=0n1n for n>=1}; Can there be a DFA possible for the language?
a) Yes
b) No
Answer: b
Explanation: It is not possible to have a count of equal number of 0 and 1 at any instant
in DFA. Thus, It is not possible to build a DFA for the given Language.
15. δ(A,1) = B, δ(A,0) =A
Δ (B, (0,1)) =C
δ(C,0) = A (Initial state =A)
String=”011001” is transit at which of the states?
a) A
b) C
c) B
d) Invalid String
Answer: a
Explanation: It is east and simple to create the table and then the corresponding
transition graph in order to get the result, at which state the given string would be
accepted.
16. How many languages are over the alphabet R?
a) countably infinite
b) countably finite
c) uncountable finite
d) uncountable infinite
Answer: d
Explanation: A language over an alphabet R is a set of strings over A which is
uncountable and infinite.
17. According to the 5-tuple representation i.e. FA= {Q, ∑, δ, q, F}
Statement 1: q ϵ Q’; Statement 2: FϵQ
a) Statement 1 is true, Statement 2 is false
b) Statement 1 is false, Statement 2 is true
c) Statement 1 is false, Statement 2 may be true
d) Statement 1 may be true, Statement 2 is false
Answer: b
Explanation: Q is the Finite set of states, whose elements i.e. the states constitute the
finite automata.
18. For a DFA accepting binary numbers whose decimal equivalent is divisible by 4,
what are all the possible remainders?
a) 0
b) 0,2
c) 0,2,4
d) 0,1,2,3
Answer: d
Explanation: All the decimal numbers on division would lead to only 4 remainders i.e.
0,1,2,3 (Property of Decimal division).
19. The maximum number of transition which can be performed over a state in a DFA?
∑= {a, b, c}
a) 1
b) 2
c) 3
d) 4
Answer: c
Explanation: The maximum number of transitions which a DFA allows for a language is
the number of elements the transitions constitute.
20. The sum of minimum and maximum number of final states for a DFA n states is
equal to:
a) n+1
b) n
c) n-1
d) n+2
Answer: a
Explanation: The maximum number of final states for a DFA can be total number of
states itself and minimum would always be 1, as no DFA exits without a final state.
Therefore, the solution is n+1.
21. It is less complex to prove the closure properties over regular languages using:
a) NFA
b) DFA
c) PDA
d) Can’t be said
Answer: a
Explanation: None.
22. Which of the following is an application of Finite Automaton?
a) Compiler Design
b) Grammar Parsers
c) Text Search
d) All of the mentioned
Answer: d
Explanation: There are many applications of finite automata, mainly in the field of
Compiler Design and Parsers and Search Engines.
23. Which of the following do we use to form an NFA from a regular expression?
a) Subset Construction Method
b) Power Set Construction Method
c) Thompson Construction Method
d) Scott Construction Method
Answer: c
Explanation: Thompson Construction method is used to turn a regular expression in an
NFA by fragmenting the given regular expression through the operations performed on
the input alphabets.
24. The total number of states to build the given language using DFA:
L= {w | w has exactly 2 a’s and at least 2 b’s}
a) 10
b) 11
c) 12
d) 13
Answer: a
Explanation: We need to make the number of a as fixed i.e. 2 and b can be 2 or more.
Thus, using this condition a finite automata can be created using 1 states.
25. A regular language over an alphabet a is one that can be obtained from
a) union
b) concatenation
c) kleene
d) All of the mentioned
Answer: d
Explanation: None.
26. Regular expression {0,1} is equivalent to
a) 0 U 1
b) 0 / 1
c) 0 + 1
d) All of the mentioned
Answer: d
Explanation: All are equivalent to union operation.
27. Precedence of regular expression in decreasing order is
a) * , . , +
b) . , * , +
c) . , + , *
d) + , a , *
Answer: a
Explanation: None
28. Regular expression Φ* is equivalent to
a) ϵ
b) Φ
c) 0
d) 1
Answer: a
Explanation: None.
29. a? is equivalent to
a) a
b) a+Φ
c) a+ϵ
d) wrong expression
Answer: c
Explanation: Zero or one time repetition of previous character .
30. ϵL is equivalent to
a) ϵ
b) Φ
c) L
d) Lϵ
Answer: c,d
Explanation: None.
31. (a+b)* is equivalent to
a) b*a*
b) (a*b*)*
c) a*b*
d) none of the mentioned
Answer: b
Explanation: None.
32. ΦL is equivalent to
a) LΦ
b) Φ
c) L
d) ϵ
Answer: a,b
Explanation: None.
33. Consider following regular expression
i) (a/b)* ii) (a*/b*)* iii) ((ϵ/a)b*)*
Which of the following statements is correct
a) i,ii are equal and ii,iii are not
b) i,ii are equal and i,iii are not
c) ii,iii are equal and i,ii are not
d) all are equal
Answer: d
Explanation: All are equivalent to (a+b)*.
34. 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
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.
35. 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
Answer: d
Explanation: Regexp processors are found in several search engines, seach and
replace mechanisms, and text processing utilities.
36. 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
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.
37. Are the given two patterns equivalent?
(1) gray|grey
(2) gr(a|e)y
a) yes
b) no
Answer: a
Explanation: Paranthesis can be used to define the scope and precedence of operators.
Thus, both the expression represents the same pattern.
38. 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
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.
39. 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
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.
40. The number of tuples in an extended Non Deterministic Finite Automaton:
a) 5
b) 6
c) 7
d) 4
Answer: a
Explanation: For NFA or extended transition function on NFA, the tuple elements
remains same i.e. 5.
41. What is wrong in the given definition?
Def: ({q0, q1, q2}, {0,1}, δ, q3, {q3})
a) The definition does not satisfy 5 Tuple definition of NFA
b) There are no transition definition
c) Initial and Final states do not belong to the Graph
d) Initial and final states can’t be same
Answer: c
Explanation: q3 does not belong to Q where Q= set of finite states.
42. What is the relation between DFA and NFA on the basis of computational power?
a) DFA > NFA
b) NFA > DFA
c) Equal
d) Can’t be said
Answer: c
Explanation: DFA is said to be a specific case of NFA and for every NFA that exists for
a given language, an equivalent DFA also exists.
43. If a string S is accepted by a finite state automaton, S=s1s2s3……sn where siϵ∑
and there exists a sequence of states r0, r1, r2…… rn such that δ(r(i), si+1) =ri+1 for
each 0, 1, …n-1, then r(n) is:
a) initial state
b) transition symbol
c) accepting state
d) intermediate state
Answer: c
Explanation: r(n) is the final state and accepts the string S after the string being
traversed through r(i) other states where I ϵ 01,2…(n-2).
44. Suppose A->xBz and B->y, then the simplified grammar would be:
a) A->xyz
b) A->xBz|xyz
c) A->xBz|B|y
d) none of the mentioned
Answer: a
Explanation: For the first step, substitute B in first production as it only produces
terminal and remove B production as it has already been utilized.
We get A->xBz|xyz and now, as B has no production, we eliminate the terms which hold
the variable B, thus the answer remain A->xyz.
45. Given Grammar: S->A, A->aA, A->e, B->bA
Which among the following productions are Useless productions?
a) S->A
b) A->aA
c) A->e
d) B->bA
Answer: d
Explanation: Some derivations are not reachable from the starting variable. As B is not
reachable from the starting variable, it is a useless symbol and thus, can be eliminated.
46. Given grammar G:
S->aS|A|C
A->a
B->aa
C->aCb
Find the set of variables thet can produce strings only with the set of terminals.
a) {C}
b) {A,B}
c) {A,B,S}
d) None of the mentioned
Answer: c
Explanation: First step: Make a set of variables that directly end up with a terminal
Second step: Modify the set with variables that produce the elements of above
generated set.
The rest variables are termed as useless.
47. Inorder to simplify a context free grammar, we can skip the following operation:
a) Removal of null production
b) Removal of useless symbols
c) Removal of unit productions
d) None of the mentioned
Answer: d
Explanation: Inorder to simplify the grammar all of the process including the removal of
null productions, unit productions and useless symbols is necessary.
Answer: a
Explanation: Step 1: Substitute A->B
Step 2: Remove B->B
Step 3: Substitute B->A
Step 4: Remove Repeated productions
49. Simplify the given grammar:
A-> a| aaA| abBc
B-> abba| b
Answer: a
Explanation: Using the substitution rules, we can simply eradicate what is useless and
thus produce the simplified result i.e. A-> a| aaA| ababbAc| abbc.
50. In context to the process of removing useless symbols, which of the following is
correct?
a) We remove the Nullable variables
b) We eliminate the unit productions
c) We eliminate products which yield no terminals
d) All of the mentioned
Answer: c
Explanation: In the process of removal of useless symbols, we want to remove
productions that can never take part in any derivation.