0% found this document useful (0 votes)
45 views81 pages

Unit 8pdf

The document contains multiple-choice questions (MCQs) related to the Theory of Computation and Compilers, specifically focusing on concepts such as finite automata, regular languages, and state transitions. Each question is accompanied by an answer and explanation, providing insights into the correct options and the underlying principles of computation theory. The content appears to be intended for exam preparation for students at Bangalore University.

Uploaded by

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

Unit 8pdf

The document contains multiple-choice questions (MCQs) related to the Theory of Computation and Compilers, specifically focusing on concepts such as finite automata, regular languages, and state transitions. Each question is accompanied by an answer and explanation, providing insights into the correct options and the underlying principles of computation theory. The content appears to be intended for exam preparation for students at Bangalore University.

Uploaded by

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

lOMoARcPSD|5982446

CSA UNIT-8 (mcq's) - Exams

Network Analysis (Bangalore University)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)
lOMoARcPSD|5982446

DITHEORY OF COMPUTATION COMPILERS


(MCQ’S)

Unit - 8

To join Test Series


Download ‘Global Online’ app

Or

@ paid WhatsApp group 8179138413

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

1. Assume the R is a relation on a set A, aRb forests too.


is partially ordered such that a and b are Which of the following make the correct
combination?
a) reflexive a) Statement 1 is false but Statement 2 and
b) transitive 3 are correct
c) symmetric b) Statement 1 and 2 are correct while 3 is
d) reflexive and transitive wrong
c) None of the mentioned statements are
Answer: d correct
Explanation: A partially ordered relation d) All of the mentioned
refers to one which is Reflexive, Transitive
and Antisymmetric. Answer: d
Explanation: It is possible to represent a
2. The non- Kleene Star operation accepts
finite automaton graphically, with nodes for
the following string of finite length over set
states, and arcs for transitions.
A = {0,1} | where string s contains even
number of 0 and 1 5. The minimum number of states required
a) 01,0011,010101 to recognize an octal number divisible by 3
b) 0011,11001100 are/is
c) ε,0011,11001100 a) 1
d) ε,0011,11001100 b) 3
c) 5
Answer: b d) 7
Explanation: The Kleene star of A, denoted
by A*, is the set of all strings obtained by Answer: b
concatenating zero or more strings from A. Explanation: According to the question,
minimum of 3 states are required to
3. A regular language over an alphabet ∑ is
recognize an octal number divisible by 3.
one that cannot be obtained from the basic
languages using the operation 6. Which of the following is a not a part of
a) Union 5-tuple finite automata?
b) Concatenation a) Input alphabet
c) Kleene* b) Transition function
d) All of the mentioned c) Initial State
d) Output Alphabet
Answer: d
Explanation: Union, Intersection, Answer: d
Concatenation, Kleene*, Reverse are all the Explanation: A FA can be represented as
closure properties of Regular Language. FA= (Q, ∑, δ, q0, F) where Q=Finite Set of
States, ∑=Finite Input Alphabet,
4. Statement 1: A Finite automata can be
δ=Transition Function, q0=Initial State,
represented graphically; Statement 2: The
F=Final/Acceptance State).
nodes can be its states; Statement 3: The
edges or arcs can be used for transitions 7. If an Infinite language is passed to
Hint: Nodes and Edges are for trees and Machine M, the subsidiary which gives a

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

finite solution to the infinite input tape is a) {aa, ab, ba, bb}
b) {aaaa, abab, ε, abaa, aabb}
a) Compiler c) {aaa, aab, aba, bbb}
b) Interpreter d) All of the mentioned
c) Loader and Linkers
d) None of the mentioned Answer: b
Explanation: ∑* represents any combination
Answer: a of the given set while ∑x represents the set
Explanation: A Compiler is used to give a of combinations with length x where x ϵ I.
finite solution to an infinite phenomenon.
Example of an infinite phenomenon is 11. Moore Machine is an application of:
Language C, etc. a) Finite automata without input
b) Finite automata with output
8. The number of elements in the set for
c) Non- Finite automata with output
the Language L={xϵ(∑r) *|length if x is at
most 2} and ∑={0,1} is d) None of the mentioned
a) 7
Answer: b
b) 6
c) 8 Explanation: Finite automaton with an
d) 5 output is categorize din two parts: Moore
M/C and Mealy M/C.
Answer: a
Explanation: ∑r= {1,0} and a Kleene* 12. In Moore machine, output is produced
operation would lead to the following over the change of:
set=COUNT{ε,0,1,00,11,01,10} =7. a) transitions
9. For the following change of state in FA, b) states
which of the following codes is an incorrect c) Both
option? d) None of the mentioned
a) δ (m, 1) =n
b) δ (0, n) =m Answer: b
c) δ (m,0) =ε Explanation: Moore machine produces an
d) s: accept = false; cin >> char; output over the change of transition states
if char = ―0‖ goto n; while mealy machine does it so for
transitions itself.
Answer: b
Explanation: δ(QX∑) = Q1 is the correct 13. In mealy machine, the O/P depends
representation of change of state. Here, δ is upon?
called the Transition function.
a) State
10. Given: ∑= {a, b} b) Previous State
L= {xϵ∑*|x is a string combination} c) State and Input
∑4 represents which among the following? d) Only Input

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

Answer: c one whose output is limited and it cannot


Explanation: Definition of Mealy Machine. be said what were the recorded outputs
previously until memorized.
14. Which of the given are correct?
a) Moore machine has 6-tuples 17. A Language for which no DFA exist is
b) Mealy machine has 6-tuples a
c) Both Mealy and Moore has 6-tuples a) Regular Language
d) None of the mentioned b) Non-Regular Language
c) May be Regular
Answer: c
d) Cannot be said
Explanation: Finite Automaton with Output
has a common definition for both the Answer: b
categories. Explanation: A language for which there is
no existence of a deterministic finite
15. Which of the following does not belong
automata is always Non Regular and
to input alphabet if S={a, b}* for any
methods like Pumping Lemma can be used
language?
to prove the same.
a) a
b) b 18. A DFA cannot be represented in the
c) e following format
d) none of the mentioned a) Transition graph
b) Transition Table
Answer: c
c) C code
Explanation: The automaton may be
d) None of the mentioned
allowed to change its state without reading
the input symbol using epsilon but this does Answer: d
not mean that epsilon has become an input Explanation: A DFA can be represented in
symbol. On the contrary, one assumes that the following formats: Transition Graph,
the symbol epsilon does not belong to any Transition Table, Transition tree/forest/Any
alphabet. programming Language.

16. Which of the following not an example


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

Answer: b
Explanation: Bounded information refers to

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

19. What the following DFA accepts?

a) Final state with loop x


b) Transitional state with loop x
c) Initial state as well as final state with loop
x
d) Insufficient Data
a) x is a string such that it ends with ‗101‘
Answer: c
b) x is a string such that it ends with ‗01‘
Explanation: The figure represents the
c) x is a string such that it has odd 1‘s and
initial as well as the final state with an
even 0‘s
iteration of x.
d) x is a strings such that it has starting and
ending character as 1 22. Which of the following will not be
accepted by the following DFA?
Answer: a
Explanation: Strings such as
{1101,101,10101} are being accepted while
{1001,11001} are not. Thus, this conclusion
leads to option a.

20. When are 2 finite states equivalent?


a) Same number of transitions
b) Same number of states
c) Same number of states as well as
transitions a) ababaabaa
d) Both are final states b) abbbaa
c) abbbaabb
Answer: c
d) abbaabbaa
Explanation: Two states are said to be
equivalent if and only if they have same Answer: a
number of states as well as transitions. Explanation: All the Strings are getting
accepted except ‗ababaabaa‘ as it is
21. What does the following figure most
directed to dumping state. Dumping state
correctly represents?

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

also refers to the reject state of the with no repetitive substrings, the number of
automata. states required to pass the string is n+1.

23. Which of the following will the given 25. Which of the following is the
DFA won‘t accept? corresponding Language to the given DFA?

a) ε
b) 11010
c) 10001010
d) String of letter count 11 a) L= {x ϵ {0, 1} * | x ends in 1 and does not
contain substring 01}
Answer: a
b) L= {x ϵ {0,1} * |x ends in 1 and does not
Explanation: As the initial state is not made
contain substring 00}
an acceptance state, thus ε will not be
c) L= {x ϵ {0,1} |x ends in 1 and does not
accepted by the given DFA. For the
contain substring 00}
automata to accept ε as an entity, one
d) L= {x ϵ {0,1} * |x ends in 1 and does not
should make the initial state as also the
contain substring 11}
final state.
Answer: b
24. The password to the admins
Explanation: The Language can be
account=‖administrator‖. The total number
anonymously checked and thus the answer
of states required to make a password-pass
can be predicted. The language needs to be
system using DFA would be
accepted by the automata (acceptance
a) 14 states
state) in order to prove its regularity.
b) 13 states
c) 12 states 26. Let ∑= {a, b, …. z} and A = {Hello, World},
d) A password pass system cannot be B= {Input, Output}, then (A*∩B) U (B*∩A)
created using DFA can be represented as:
a) {Hello, World, Input, Output, ε}
Answer: a
b) {Hello, World, ε}
Explanation: For a string of n characters

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

c) {Input, Output, ε} Answer: a


d) {} Explanation:

Answer: d
Explanation: Union operation creates the
universal set by combining all the elements
of first and second set while intersection
operation creates a set of common
elements of the first and the second state.

27. Let the given DFA consist of x states.


Find x-y such that y is the number of states
on minimization of DFA?

29. For the DFA given below compute the


following:
Union of all possible combinations at state
7,8 and 9.

a) 3
b) 2
c) 1
d) 4

Answer: b
Explanation: Use the equivalence theorem
or Myphill Nerode theorem to minimize the
a) {aba, ac, cc, ca, cb, bc, bab, ca}
DFA.
b) {bab, bc, ac, aba, ca, aac, ccb}
28. For a machine to surpass all the letters c) {cc, ca, cb, aba, bab, ac}
of alphabet excluding vowels, how many d) {aba, ac, cc, ca, cb, bc, bab, caa}
number of states in DFA would be required?
Answer: d
a) 3
Explanation: The string a state receives is
b) 2
the combination of all input alphabets
c) 22
which lie across the path covered.
d) 27

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

30. Given L= {Xϵ∑*= {a, b} |x has equal Answer: a


number of a, s and b‘s}. Explanation: It is east and simple to create
Which of the following property satisfy the the table and then the corresponding
regularity of the given language? transition graph in order to get the result, at
a) Regularity is dependent upon the length which state the given string would be
of the string accepted.
b) Regularity is not dependent upon the
33. How many languages are over the
length of the string
alphabet R?
c) Can‘t be said for a particular string of a
a) countably infinite
language
b) countably finite
d) It may depend on the length of the string
c) uncountable finite
Answer: b d) uncountable infinite
Explanation: DFA can be made for infinite
Answer: d
language with an infinite length. Thus,
Explanation: A language over an alphabet R
dependency over length is unfruitful.
is a set of strings over A which is
31. Given: uncountable and infinite.
L= {xϵ∑= {0,1} |x=0n1n for n>=1}; Can there
34. According to the 5-tuple representation
be a DFA possible for the language?
i.e. FA= {Q, ∑, δ, q, F}
a) Yes
Statement 1: q ϵ Q‘; Statement 2: FϵQ
b) No
a) Statement 1 is true, Statement 2 is false
Answer: b b) Statement 1 is false, Statement 2 is true
Explanation: It is not possible to have a c) Statement 1 is false, Statement 2 may be
count of equal number of 0 and 1 at any true
instant in DFA. Thus, It is not possible to d) Statement 1 may be true, Statement 2 is
build a DFA for the given Language. false

32. δ(A,1) = B, δ(A,0) =A Answer: b


Δ (B, (0,1)) =C Explanation: Q is the Finite set of states,
δ(C,0) = A (Initial state =A) whose elements i.e. the states constitute
String=‖011001‖ is transit at which of the the finite automata.
states?
35. δˆ tells us the best:
a) A
a) how the DFA S behaves on a word u
b) C
b) the state is the dumping state
c) B
c) the final state has been reached
d) Invalid String
d) Kleene operation is performed on the set

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

Answer: a
Explanation: δ or the Transition function
describes the best, how a DFA behaves on a
string where to transit next, which direction
to take.

36. Which of the following option is


correct?
A= {{abc, aaba}. {ε, a, bb}}
a) abcbb ₵ A
b) ε₵A a) divisible by 3
c) ε may not belong to A b) divisible by 2
d) abca ₵ A c) divisible by 2 and 3
d) divisible by 3 and 2
Answer: b
Explanation: As the question has dot Answer: d
operation, ε will not be a part of the Explanation: The given DFA accepts all the
concatenated set. Had it been a union binary strings such that they are divisible by
operation, ε would be a part of the 3 and 2.Thus, it can be said that it also
operated set. accepts all the strings which is divisible by 6.

37. For a DFA accepting binary numbers 39. Given:


whose decimal equivalent is divisible by 4, L1= {xϵ ∑*|x contains even no‘s of 0‘s}
what are all the possible remainders? L2= {xϵ ∑*|x contains odd no‘s of 1‘s}
a) 0 No of final states in Language L1 U L2?
b) 0,2 a) 1
c) 0,2,4 b) 2
d) 0,1,2,3 c) 3
d) 4
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).

38. Which of the following x is accepted by


the given DFA (x is a binary string ∑= {0,1})?

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

Answer: c fixed while the in degree depends on the


Explanation: number of states in the DFA and that
cannot be determined without the
dependence over the Language.

42. Transition function maps.


a) Σ * Q -> Σ
b) Q * Q -> Σ
c) Σ * Σ -> Q
d) Q * Σ -> Q

Answer:d
Explanation: Inputs are state and input
string output is states.
40. The maximum number of transition
43. Number of states require to accept
which can be performed over a state in a
string ends with 10.
DFA?
a) 3
∑= {a, b, c}
b) 2
a) 1
c) 1
b) 2
d) can‘t be represented.
c) 3
d) 4 Answer:a
Explanation: This is minimal finite
Answer: c
automata.
Explanation: The maximum number of
transitions which a DFA allows for a 44. Extended transition function is .
language is the number of elements the a) Q * Σ* -> Q
transitions constitute. b) Q * Σ -> Q
c) Q* * Σ* -> Σ
41. The maximum sum of in degree and out
d) Q * Σ -> Σ
degree over a state in a DFA can be
determined as: Answer:a
∑= {a, b, c, d} Explanation: This takes single state and
a) 4+4 string of input to produce a state.
b) 4+16
45. δ*(q,ya) is equivalent to .
c) 4+0
a) δ((q,y),a)
d) depends on the Language
b) δ(δ*(q,y),a)
Answer: d c) δ(q,ya)
Explanation: The out degree for a DFA I d) independent from δ notation

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

Answer:b c) 2
Explanation: First it parse y string after that d) None of the mentioned
it parse a.
Answer:b
46. String X is accepted by finite automata if. Explanation: Finite automata doesn‘t
a) δ*(q,x) E A require any stack operation .
b) δ(q,x) E A
50. Number of final state require to accept
c) δ*(Q0,x) E A
Φ in minimal finite automata.
d) δ(Q0,x) E A
a) 1
Answer:c b) 2
Explanation: If automata starts with starting c) 3
state and after finite moves if reaches to d) None of the mentioned
final step then it called accepted.
Answer:d
47. Languages of a automata is Explanation: No final state requires.
a) If it is accepted by automata
51. Given Language: L= {ab U aba}*
b) If it halts
If X is the minimum number of states for a
c) If automata touch final state in its life
DFA and Y is the number of states to
time
construct the NFA,
d) All language are language of automata
|X-Y|=?
Answer:a a) 2
Explanation: If a string accepted by b) 3
automata it is called language of automata. c) 4
d) 1
48. Language of finite automata is.
a) Type 0 Answer: a
b) Type 1 Explanation: Construct the DFA and NFA
c) Type 2 individually, and the attain the difference of
d) Type 3 states.

Answer:d 52. An automaton that presents output


Explanation: According to Chomsky based on previous state or current input:
classification. a) Acceptor
b) Classifier
49. Finite automata requires minimum
c) Transducer
number of stacks.
d) None of the mentioned.
a) 1
b) 0 Answer: c
Explanation: A transducer is an automaton

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

that produces an output on the basis of a) Statement 1 is correct because


what input has been given currently or Statement 2 is correct
previous state. b) Statement 2 is correct because
Statement 2 is correct
53. If NFA of 6 states excluding the initial
c) Statement 2 is false and Statement 1 is
state is converted into DFA, maximum
false
possible number of states for the DFA is ?
d) Statement 1 is false because Statement 2
a) 64
is false
b) 32
c) 128 Answer: b
d) 127 Explanation: DFA is a specific case of NFA.

Answer: c 56. Given Language L= {xϵ {a, b}*|x contains


Explanation: The maximum number of sets aba as its substring}
for DFA converted from NFA would be not Find the difference of transitions made in
greater than 2n. constructing a DFA and an equivalent NFA?
a) 2
54. NFA, in its name has ‘non-deterministic‘
b) 3
because of :
c) 4
a) The result is undetermined
d) Cannot be determined.
b) The choice of path is non-deterministic
c) The state to be transited next is non- Answer: a
deterministic Explanation: The individual Transition
d) All of the mentioned graphs can be made and the difference of
transitions can be determined.
Answer: b
Explanation: Non deterministic or 57. The construction time for DFA from an
deterministic depends upon the definite equivalent NFA (m number of node)is:
path defined for the transition from one a) O(m2)
state to another or undefined(multiple b) O(2m)
paths). c) O(m)
d) O(log m)
55. Which of the following is correct
proposition? Answer: b
Statement 1: Non determinism is a Explanation: From the coded NFA-DFA
generalization of Determinism. conversion.
Statement 2: Every DFA is automatically an
58. If n is the length of Input string and m is
NFA
the number of nodes, the running time of
DFA is x that of NFA.Find x?

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

a) 1/m2 a) 0+01
b) 2m b) {0} U {01}
c) 1/m c) {0} U {0}{1}
d) log m d) {0} ^ {01}

Answer: a Answer: d
Explanation: Running time of DFA: O(n) and Explanation: The given option represents {0,
Running time of NFA =O(m2n). 01} in different forms using set operations
and Regular Expressions. The operator like
59. L is a regular Language if and only If the
^, v, etc. are logical operation and they form
set of classes of IL is finite.
invalid regular expressions when used.
a) Equivalence
b) Reflexive 62. According to the given language, which
c) Myhill among the following expressions does it
d) Nerode corresponds to?
Language L={xϵ{0,1}|x is of length 4 or less}
Answer: a
Explanation: According to Myhill Nerode a) (0+1+0+1+0+1+0+1)4
theorem, the corollary proves the given b) (0+1)4
statement correct for equivalence classes. c) (01)4
d) (0+1+ε)4
60. A language can be generated from
simple primitive language in a simple way if Answer: d
and only if Explanation: The extended notation would
a) It is recognized by a device of infinite be (0+1)4 but however, we may allow some
states or all the factors to be ε. Thus ε needs to be
b) It takes no auxiliary memory included in the given regular expression.
c) Both are correct
63. Which among the following looks similar
d) Both are wrong
to the given expression?
Answer: b ((0+1). (0+1)) *
Explanation: A language is regular if and a) {xϵ {0,1} *|x is all binary number with
only if it can be accepted by a finite even length}
automaton. Secondly, It supports no b) {xϵ {0,1} |x is all binary number with even
concept of auxiliary memory as it loses the length}
data as soon as the device is shut down. c) {xϵ {0,1} *|x is all binary number with odd
length}
61. Which of the following does not
d) {xϵ {0,1} |x is all binary number with odd
represents the given language?
length}
Language: {0,01}

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

Answer: a Answer: a
Explanation: The given regular expression Explanation: ε+1*(011) *(1*(011) *) *
corresponds to a language of binary strings ε + RR*= ε + R*R= ε + R+= R*
which is of even length including a length of
67. P, O, R be regular expression over ∑, P is
0.
not ε, then
64. A finite automaton accepts which type R=Q + RP has a unique solution:
of language:
a) Q*P
a) Type 0
b) QP*
b) Type 1
c) Q*P*
c) Type 2
d) (P*O*) *
d) Type 3
Answer: b
Answer: d
Explanation: The given statement is the
Explanation: Type 3 refers to Regular
Arden‘s Theorem and it tends to have a
Languages which is accepted by a finite
unique solution as QP*.
automaton.
Let P and Q be regular expressions,
65. Which among the following are R=Q+RP
incorrect regular identities? R=Q+(Q+RP) P
a) εR=R R=Q+((Q+RP) +RP)
b) ε*=ε +P=Q+QP+RPP+RPP=Q+QP+(Q+RP)
c) Ф*=ε PP+(Q+RP)
d) RФ=R PP=Q+QP+QPP+RPPP+QPP+RPPP,
If we do this recursively, we get:
Answer: d
R= QP*
Explanation: There are few identities over
Regular Expressions which include: 68. Arden‘s theorem is true for:
RФ=ФR=Ф≠R a) More than one initial states
b) Null transitions
66. Simplify the following regular
c) Non-null transitions
expression:
d) None of the mentioned
ε+1*(011) *(1*(011) *) *
a) (1+011) * Answer: c
b) (1*(011) *) Explanation: Arden‘s theorem strictly
c) (1+(011) *) * assumes the following;
d) (1011) * a) No null transitions in the transition
diagrams
b) True for only single initial state

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

69. Which of the following is correct? between a regular expression R and the
Statement 1: ε represents a single string in language it represents; we write L(R) to be
the set. the language of R.
Statement 2: Ф represents the language
72. Let for ∑= {0,1} R= (∑∑∑) *, the language
that consist of no string.
of R would be
a) Statement 1 and 2 both are correct
a) {w | w is a string of odd length}
b) Statement 1 is false but 2 is correct
b) {w | w is a string of length multiple of 3}
c) Statement 1 and 2 both are false
c) {w | w is a string of length 3}
d) There is no difference between both the
d) All of the mentioned
statements, ε and Ф are different notation
for same reason Answer: b
Explanation: This regular expression can be
Answer: a
used to eliminate the answers and get the
Explanation: ε represents a single string in
result. The length can be even and as well
the set namely, the empty string while
more than 3 when R= (∑∑∑) (∑∑∑)
Statement 2 is also correct.
(particular case).
70. The appropriate precedence order of
73. If ∑= {0,1}, then Ф* will result to:
operations over a Regular Language is
a) ε
a) Kleene, Union, Concatenate
b) Ф
b) Kleene, Star, Union
c) ∑
c) Kleene, Dot, Union
d) None of the mentioned
d) Star, Union, Dot
Answer: a
Answer: c
Explanation: The star operation brings
Explanation: If a regular language
together any number of strings from the
expression is given, the appropriate order
language to get a string in the result. If the
of precedence if the parenthesis is ignored
language is empty, the star operation can
is: Star or Kleene, Dot or Concatenation,
put together 0 strings, resulting only the
Union or Plus.
empty string.
71. Regular Expression R and the language it
74. Which of the following is correct?
describes can be represented as:
Statement 1: ε represents a single string in
a) R, R(L)
the set.
b) L(R), R(L)
Statement 2: Ф represents the language
c) R, L(R)
that consist of no string.
d) All of the mentioned
a) Statement 1 and 2 both are correct
Answer: c b) Statement 1 is false but 2 is correct
Explanation: When we wish to distinguish c) Statement 1 and 2 both are false

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

d) There is no difference between both the c) {w | w is a string of length 3}


statements, ε and Ф are different notation d) All of the mentioned
for same reason
Answer: b
Answer: a Explanation: This regular expression can be
Explanation: ε represents a single string in used to eliminate the answers and get the
the set namely, the empty string while result. The length can be even and as well
Statement 2 is also correct. more than 3 when R= (∑∑∑) (∑∑∑)
(particular case).
75. The appropriate precedence order of
operations over a Regular Language is 78. If ∑= {0,1}, then Ф* will result to:
a) Kleene, Union, Concatenate a) ε
b) Kleene, Star, Union b) Ф
c) Kleene, Dot, Union c) ∑
d) Star, Union, Dot d) None of the mentioned

Answer: c Answer: a
Explanation: If a regular language Explanation: The star operation brings
expression is given, the appropriate order together any number of strings from the
of precedence if the parenthesis is ignored language to get a string in the result. If the
is: Star or Kleene, Dot or Concatenation, language is empty, the star operation can
Union or Plus. put together 0 strings, resulting only the
empty string.
76. Regular Expression R and the language it
describes can be represented as: 79. Which of the following is same as the
a) R, R(L) given DFA?
b) L(R), R(L)
c) R, L(R)
d) All of the mentioned

Answer: c
Explanation: When we wish to distinguish
between a regular expression R and the
language it represents; we write L(R) to be
the language of R.
a) (0+1)*001(0+1)*
77. Let for ∑= {0,1} R= (∑∑∑) *, the language b) 1*001(0+1)*
of R would be c) (01)*(0+0+1)(01)*
a) {w | w is a string of odd length} d) None of the mentioned
b) {w | w is a string of length multiple of 3}

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

Answer: a Answer: c
Explanation: There needs to be 001 Explanation:
together in the string as an essential
substring. Thus, the other components can
be anything, 0 or 1 or e.

80. 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 82. Which of the given regular expressions
expression can be represented using NFA correspond to the automata shown?
with e moves
d) Regular expression is just another
representation for any automata definition

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.

81. The total number of states required to


automate the given regular expression
(00)*(11)*
a) 3 a) (110+1)*0
b) 4 b) (11+110)*1
c) 5
c) (110+11)*0
d) 6
d) (1+110)*1

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.

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

83. Which of the following is an utility of and accepting states


state elimination phenomenon? d) Get the resulting regular expression by
a) DFA to NFA direct calculation
b) NFA to DFA
Answer: b
c) DFA to Regular Expression
Explanation: While eliminating the states,
d) All of the mentioned
we unify multiple transitions to one
Answer: c transition that contains union of input and
Explanation: We use this algorithm to not the vice versa.
simplify a finite automaton to regular
86. A regular language over an alphabet a is
expression or vice versa. We eliminate
one that can be obtained from
states while converting a given finite
a) union
automata to its corresponding regular
b) concatenation
expression.
c) kleene
84. If we have more than one accepting d) All of the mentioned
states or an accepting state with an
Answer: d
outdegree, which of the following actions
Explanation: None.
will be taken?
a) addition of new state 87. Regular expression {0,1} is equivalent to
b) removal of a state a) 0 U 1
c) make the newly added state as final b) 0 / 1
d) more than one option is correct c) 0 + 1
d) All of the mentioned
Answer: d
Explanation: If there is more than one Answer: d
accepting state or if the single accepting Explanation: All are equivalent to union
state as an out degree , add a new operation.
accepting state, make all other states non
accepting, and hold an e-transitions from 88. Precedence of regular expression in
each former accepting state to the new decreasing order is
accepting state. a) * , . , +
b) . , * , +
85. Which of the following is not a step in c) . , + , *
elimination of states procedure? d) + , a , *
a) Unifying all the final states into one using
e-transitions Answer: a
b) Unify single transitions to multi Explanation: None.
transitions that contains union of input
c) Remove states until there is only starting

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

89. Regular expression Φ* is equivalent to c) L


a) ϵ d) ϵ
b) Φ
Answer: a,b
c) 0
Explanation: None.
d) 1
94. Which of the following pair of regular
Answer: a
expression are not equivalent?
Explanation: None.
a) 1(01)* and (10)*1
90. a? is equivalent to b) x(xx)* and (xx)*x
a) a c) (ab)* and a*b*
b) a+Φ d) x+ and x*x+
c) a+ϵ
Answer: c
d) wrong expression
Explanation: (ab)*=(a*b*)*.
Answer: c
95. Consider following regular expression
Explanation: Zero or one time repetition of
i) (a/b)* ii) (a*/b*)* iii) ((ϵ/a)b*)*
previous character .
Which of the following statements is
91. ϵL is equivalent to correct
a) ϵ a) i,ii are equal and ii,iii are not
b) Φ b) i,ii are equal and i,iii are not
c) L c) ii,iii are equal and i,ii are not
d) Lϵ d) all are equal

Answer: c,d Answer: d


Explanation: None. Explanation: All are equivalent to (a+b)*.

92. (a+b)* is equivalent to 96. How many strings of length less than 4
a) b*a* contains the language described by the
b) (a*b*)* regular expression (x+y)*y(a+ab)*?
c) a*b* a) 7
d) none of the mentioned b) 10
c) 12
Answer: b
d) 11
Explanation: None.
Answer: c
93. ΦL is equivalent to
Explanation: string of length 0 = Not
a) LΦ
possible (because y is always present).
b) Φ
string of length 1 = 1 (y)
string of length 2 = 3 (xy,yy,ya)

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

string of length 3 = 8 Answer: b


(xxy,xyy,yxy,yyy,yaa,yab,xya,yya) Explanation: Except b all are regular
expression*.
97. Which of the following is true?
a) (01)*0 = 0(10)* 101. Which of the following do Regexps do
b) (0+1)*0(0+1)*1(0+1) = (0+1)*01(0+1)* not find their use in?
c) (0+1)*01(0+1)*+1*0* = (0+1)* a) search engines
d) All of the mentioned b) word processors
c) sed
Answer: d
d) none of the mentioned
Explanation: None.
Answer: d
98. A language is regular if and only if
Explanation: Regexp processors are found
a) accepted by DFA
in several search engines, seach and replace
b) accepted by PDA
mechanisms, and text processing utilities.
c) accepted by LBA
d) accepted by Turing machine 102. Which of the following languages have
built in regexps support?
Answer: a
a) Perl
Explanation: All of above machine can
b) Java
accept regular language but all string
c) Python
accepted by machine is regular only for
d) C++
DFA.
Answer: a
99. Regular grammar is
Explanation: Many languages come with
a) context free grammar
built in support of regexps like Perl,
b) non context free grammar
Javascript, Ruby etc. While some provide
c) english grammar
support using standard libraries like .NET,
d) none of the mentioned
Java, Python, C++, C and POSIX.
Answer: a
103. The following is/are an approach to
Explanation: Regular grammar is subset of
process a regexp:
context free grammar.
a) Contruction of NFA and subsequently, a
100. Which of the following is not a regular DFA.
expression? b) Thompson‘s Contruction Algorithm
a) [(a+b)*-(aa+bb)]* c) Both (a) and (b)
b) [(0+1)-(0b+a1)*(a+b)]* d) None of the mentioned
c) (01+11+10)*
Answer: c
d) (1+2+0)*(1+2)*
Explanation: A regexp processor translates

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

the syntax into internal representation Answer: d


which can be executed and matched with a Explanation: Regular expressions are used
string and that internal representation can by different commands in Unix like ed, sed,
have several approaches like the ones grep, awk, vi, etc. Sed stands for stream
mentioned. editor which is exclusively used for
executing scripts.
104. Are the given two patterns equivalent?
(1) gray|grey 107. Lexemes can be referred to as:
(2) gr(a|e)y a) elements of lexicography
a) yes b) sequence of alphanumeric characters in a
b) no token
c) lexical errors
Answer: a
d) none of the mentioned
Explanation: Paranthesis can be used to
define the scope and precedence of Answer: b
operators. Thus, both the expression Explanation: A lexeme is a string of
represents the same pattern. characters that form a syntactic unit. It is
reasonable to say that is the sequence of
105. Which of the following are not
alphanumeric characters in a token.
quantifiers?
a) Kleene plus + 108. If the lexical analyser finds a lexeme
b) Kleene star * with the same name as that of a reserved
c) Question mark ? word,it
d) None of the mentioned a) overwrites the word
b) overwrites the functionality
Answer: d
c) generates an error
Explanation: A quantifier after a token
d) something else
specifies how often the preceding element
is allowed to occur. ?, *, +, {n}, {min, }, {min, Answer: c
max} are few quantifiers we use in regexps Explanation: Reserved words are known as
implementations. keywords and they are specific and
reserved with its functionality to a
106. Which among the following is not a
language. Thus, getting an input with the
UNIX command for regular expressions?
same name by the analyzer will generate an
a) ed
error.
b) sed
c) vi 109. The methodology to show an error
d) none of the mentioned when the analyzer faces a keyword over an
user‘s input is based on:
a) rule priority

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

b) longest match rule Answer: b


c) keyword-out rule Explanation: The Longest Match rule states
d) none of mentioned that the lexeme scanned should be
determined on the basis of longest match
Answer: a
among all the token available.
Explanation: The lexical analyzer follows the
rule priority where its prioritizes keywords 112. The output of the lexical and syntax
over an input it gets with the same name as analyzer can stated as:
that of the keyword and thus generates an a) parse stream, parse tree
error. b) token tree, parse tree
c) token stream, parse tree
110. State true or false:
d) all of the mentioned
Statement: A lexical analyzer reads the
source code line by line. Answer: c
a) True Explanation: The lexical analyzer outputs
b) False the stream of token which is taken up by
syntax analyzer one by one against the
Answer: b
production rule and parse tree is generated.
Explanation: A lexical analyzer reads the
source code letter by letter and when it 113. Which among the following is not a
encounters a space or an operator or any tool to construct lexical analyzer from a
special character, it decides that the word is regular expression?
completed. a) lex
b) flex
111. Which among the following statement
c) jflex
is correct?
d) none of the mentioned
Statement 1: When the analyzer scans ‗int‘
and ‗intvalue‘, it is not able to decide Answer: d
whether the int leads to a keyword or an Explanation: Lexical analysis is done using
identifier. few tools such as lex, flex and jflex. Jflex is a
Statement 2: Longest Match Rule computer program that generates lexical
analyzers (also known as lexers or scanners)
a) Statement 1 is assertion, Statement 2 is
and works apparently like lex and flex. Lex is
the reason
commonly used with yacc parser generator.
b) Statement 1 is assertion, Statement 2 is
the solution 114. A program that performs lexical
c) There is no such Statement 2 analysis is termed as:
d) This is not a function of Lexical Analyzer a) scanner
b) lexer

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

c) tokenizer 117. Which of the following regular


d) all of the mentioned expression is equivalent to R(1,0)?
R(1,0)={111*}*
Answer: d
a) (11+111)*
Explanation: A program which performs
b) (111+1111)*
lexical analysis is called lexer, scanner or
c) (111+11*)*
lexer. Nowadays, lexer is combined with a
d) All of the mentioned
parser which allows syntactic analysis.
Answer: a
115. Which phase of compiler includes
Explanation: What we observe from the
Lexical Analysis?
question is that, it includes e and 11 and
a) 1
any number of 1‘s then. Therefore, its
b) 2
simplifies when we write the same reg.
c) 3
Expression as (11+111)*.
d) Its primary function, not in any phase
118. All the regular languages can have one
Answer: a
or more of the following descriptions:
Explanation: The first phase of compilation
i) DFA ii) NFA iii) e-NFA iv) Regular
process is called lexical analysis. It
Expressions
fragments the source code into token which
Which of the following are correct?
is the smallest programming unit of a
a) i, ii, iv
program.
b) i, ii, iii
116. The minimum length of a string {0,1}* c) i, iv
not in the language corresponding to the d) i, ii, iii, iv
given regular expression:
Answer: d
(0*+1*)(0*+1*)(0*+1*)
Explanation: The class of languages known
a) 3
as the regular language has atleast four
b) 4
different descriptions: i) DFA ii) NFA iii) e-
c) 5
NFA iv) Regular Expressions
d) 6
119. Which of the technique can be used to
Answer: b
prove that a language is non regular?
Explanation: 0101 or 1010 the strings with
a) Ardens theorem
minimum length on {0,1}* which does not
b) Pumping Lemma
belong to the language of the given regular
c) Ogden‘s Lemma
expression.Other strings like 111, 000,
d) None of the mentioned
1101, etc are accepted by the language .
Answer: b
Explanation: We use the powerful

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

technique called Pumping Lemma, for 122. If L is DFA-regular, L‘ is


showing certain languages not to be a) Non regular
regular. We use Ardens theorem to find out b) DFA-regular
a regular expression out of a finite c) Non-finite
automaton. d) None of the mentioned

120. Which of the following language Answer: b


regular? Explanation: This is a simple example of a
a) {aibi|i>=0} closure property: a property saying that the
b) {aibi|0<i<5} set of DFA-regular languages is closed under
c) {aibi|i>=1} certain operations.
d) None of the mentioned
123. Which of the following options is
Answer: b incorrect?
Explanation: Here, i has limits i.e. the a) A language L is regular if and only if ~L
language is finite, contains few elements has finite number of equivalent classes.
and can be graphed using a deterministic b) Let L be a regular language. If ~L has k
finite automata. Thus, it is regular. Others equivalent classes, then any DFA that
can be proved non regular using Pumping recognizes L must have atmost k states.
lemma. c) A language L is NFA-regular if and only if
it is DFA-regular.
121. Which of the following are non
d) None of the mentioned
regular?
a) The set of strings in {a,b}* with an even Answer: b
number of b‘s Explanation: Let L be a regular language. If
b) The set of strings in {a, b, c}* where there ~L has k equivalent classes, then any DFA
is no c anywhere to the left of a that recognizes L must have atleast k states.
c) The set of strings in {0, 1}* that encode,
124. Myphill Nerode does the following:
in binary, an integer w that is a multiple of
a) Minimization of DFA
3. Interpret the empty strings e as the
b) Tells us exactly when a language is
number 0.
regular
d) None of the mentioned
c) Both (a) and (b)
Answer: d d) None of the mentioned
Explanation: All of the given languages are
Answer: c
regular and finite and thus, can be
Explanation: In automata theory, the
represented using respective deterministic
Myphill Nerode theorem provides a
finite automata. We can also use mealy or
necessary and sufficient condition for a
moore machine to represent remainders for
language to be regular. The Myphill Nerode
option c.

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

theorem can be used to show a language L 127. Relate the following statement:
is regular by proving that the number of Statement: All sufficiently long words in a
equivalence classes of RL(relation) is finite. regular language can have a middle section
of words repeated a number of times to
125. Given languages:
produce a new word which also lies within
i) {anbn|n>=0}
the same language.
ii) <div>n</div>n
a) Turing Machine
iii) {w∈ {a,b}∗ | #a(w)=#b(w)}, # represents
b) Pumping Lemma
occurrences
c) Arden‘s theorem
Which of the following is/are non regular?
d) None of the mentioned
a) i, iii
b) i Answer: b
c) iii Explanation: Pumping lemma defines an
d) i, ii, iii essential property for every regular
language in automata theory. It has certain
Answer: d
rules which decide whether a language is
Explanation: There is no regular expression
regular or not.
that can parse HTML documents. Other
options are also non-regular as they cannot 128. While applying Pumping lemma over a
be drawn into finite automaton. language, we consider a string w that
belong to L and fragment it into
126. Finite state machine are not able to
parts.
recognize Palindromes because:
a) 2
a) Finite automata cannot deterministically
b) 5
find the midpoint
c) 3
b) Finite automata cannot remember
d) 6
arbitarily large amount of data
c) Even if the mid point is known, it cannot Answer: c
find whether the second half matches the Explanation: We select a string w such that
first w=xyz and |y|>0 and other conditions.
d) All of the mentioned However, there exists an integer n such that
|w|>=n for any wÎL.
Answer: d
Explanation: It is the disadvantage or lack of 129. If we select a string w such that w∈ L,
property of a DFA that it cannot remember and w=xyz. Which of the following portions
an arbitrarily such large amount of data cannot be an empty string?
which makes it incapable of accepting such a) x
languages like palindrome, reversal, etc. b) y
c) z
d) all of the mentioned

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

Answer: b 132. Fill in the blank in terms of p, where p


Explanation: The lemma says, the portion y is the maximum string length in L.
in xyz cannot be zero or empty i.e. |y|>0, Statement: Finite languages trivially satisfy
this condition needs to be fulfilled to check the pumping lemma by having n =
the conclusion condition. a) p*1
b) p+1
130. Let w= xyz and y refers to the middle
c) p-1
portion and |y|>0.What do we call the
d) None of the mentioned
process of repeating y 0 or more times
before checking that they still belong to the Answer: b
language L or not? Explanation: Finite languages trivially satisfy
a) Generating the pumping lemma by having n equal to
b) Pumping the maximum string length in l plus 1.
c) Producing
133. Which kind of proof is used to prove
d) None of the mentioned
the regularity of a language?
Answer: b a) Proof by contradiction
Explanation: The process of repeatation is b) Direct proof
called pumping and so, pumping is the c) Proof by induction
process we perform before we check d) None of the mentioned
whether the pumped string belongs to L or
Answer: a
not.
Explanation: We use the method of proof
131. There exists a language L. We define a by contradiction in pumping lemma to
string w such that w∈ L and w=xyz and |w| prove that a language is regular or not.
>=n for some constant integer n.What can
134. The language of balanced paranthesis
be the maximum length of the substring xy
is
i.e. |xy|<=?
a) regular
a) n
b) non regular
b) |y|
c) may be regular
c) |x|
d) none of the mentioned
d) none of the mentioned
Answer: b
Answer: a
Explanation: Given n, there is a string of
Explanation: It is the first conditional
balanced parentheses that begins with
statement of the lemma that states that
more than p left parentheses, so that y will
|xy|<=n, i.e. the maximum length of the
contain entirely of left parentheses. By
substring xy in w can be n only.
repeating y, we can produce a string that
does not contain the same number of left

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

and right parentheses, and so they cannot c) both (a) and (b)
be balanced. d) none of the mentioned

135. State true or false: Answer: c


Statement: Pumping lemma gives a Explanation: Collisions are inevitable in a
necessary but not sufficient condition for a hash table because the number of possible
language to be regular. keys exceeds the number of indices in the
a) true array.
b) false
138. The entity which generate Language is
Answer: a termed as:
Explanation: The converse of the lemma is a) Automata
not true. There may exists some language b) Tokens
which satisfy all the conditions of the c) Grammar
lemma and still be non-regular. d) Data

136. Which of the following is/are an Answer: c


example of pigeon hole principle? Explanation: The entity which accepts a
a) Softball team language is termed as Automata while the
b) Sock picking one which generates it is called Grammar.
c) Hair counting Tokens are the smallest individual unit of a
d) All of the mentioned program.

Answer: d 139. Production Rule: aAb->agb belongs to


Explanation: There are several applications which of the following category?
of pigeonhole principle: a) Regular Language
Example: The softball team: Suppose 7 b) Context free Language
people who want to play softball(n=7 c) Context Sensitive Language
items), with a limitation of only 4 softball d) Recursively Ennumerable Language
teams to choose from. The pigeonhole
Answer: c
principle tells us that they cannot all play
Explanation: Context Sensitive Language or
for different teams; there must be atleast
Type 1 or Linearly Bounded Non
one team featuring atleast two of the seven
deterministic Language has the production
players.
rule where the production is context
137. Pigeonhole principle can be applied in dependent i.e. aAb->agb.
the following computer science algorithms:
140. Which of the following statement is
a) hashing algorithm
false?
b) lossless compression algorithm
a) Context free language is the subset of

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

context sensitive language a) L is a set of numbers divisible by 2


b) Regular language is the subset of context b) L is a set of binary complement
sensitive language c) L is a set of string with odd number of 0
c) Recursively ennumerable language is the d) L is a set of 0n1n
super set of regular language
Answer: d
d) Context sensitive language is a subset of
Explanation: There exists no finite automata
context free language
to accept the given language i.e. 0n1n. For
Answer: d other options, it is possible to make a dfa or
Explanation: Every regular language can be nfa representing the language set.
produced by context free grammar and
143. Which of the expression is
context free language can be produced by
appropriate?
context sensitive grammar and so on.
For production p: a->b where a∈ V and
b∈
a) V
b) S
c) (V+∑)*
d) V+ ∑

Answer: c
Explanation: According to the definition, the
starting variable can produce another
variable or any terminal or a variable which
141. The Grammar can be defined as: G=(V, leads to terminal.
∑, p, S)
In the given definition, what does S 144. For S->0S1|e for ∑={0,1}*, which of the
represents? following is wrong for the language
a) Accepting State produced?
b) Starting Variable a) Non regular language
c) Sensitive Grammar b) 0n1n | n>=0
d) None of these c) 0n1n | n>=1
d) None of the mentioned
Answer: b
Explanation: G=(V, ∑, p, S), here V=Finite set Answer: d
of variables, ∑= set of terminals, p= finite Explanation: L={e, 01, 0011, 000111,
productions, S= Starting Variable. ……0n1n }. As epsilon is a part of the set,
thus all the options are correct implying
142. Which among the following cannot be none of them to be wrong.
accepted by a regular grammar?

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

145. The minimum number of productions 148. Which of the following is not a notion
required to produce a language consisting of Context free grammars?
of palindrome strings over ∑={a,b} is a) Recursive Inference
a) 3 b) Derivations
b) 7 c) Sentential forms
c) 5 d) All of the mentioned
d) 6
Answer: d
Answer: c Explanation: The following are the notions
Explanation: The grammar which produces to express Context free grammars:
a palindrome set can be written as: a) Recursive Inferences
S-> aSa | bSb | e | a | b b) Derivations
L={e, a, b, aba, abbbaabbba…..} c) Sentential form
d) Parse trees
146. Which of the following statement is
correct? 149. State true or false:
a) All Regular grammar are context free but Statement: The recursive inference
not vice versa procedure determines that string w is in the
b) All context free grammar are regular language of the variable A, A being the
grammar but not vice versa starting variable.
c) Regular grammar and context free a) true
grammar are the same entity b) false
d) None of the mentioned
Answer: a
Answer: a Explanation: We apply the productions of
Explanation: Regular grammar is a subset of CFG to infer that certain strings are in the
context free grammar and thus all regular language of a certain variable.
grammars are context free.
150. Which of the following is/are the
147. Are ambiguous grammar context free? suitable approaches for inferencing?
a) Yes a) Recursive Inference
b) No b) Derivations
c) Both Recursive Inference and Derivations
Answer: a
d) None of the mentioned
Explanation: A context free grammar G is
ambiguous if there is atleast one string in Answer: c
L(G) which has two or more distinct Explanation: Two inference approaches:
leftmost derivations. 1. Recursive inference, using productions
from body to head

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

2. Derivations, using productions from head make the expression correct.


to body L(G)={w in T*|S→*w}
a) 0 Errors
151. If w belongs to L(G), for some CFG,
b) 1 Error
then w has a parse tree, which defines the
c) 2 Error
syntactic structure of w. w could be:
d) Invalid Expression
a) program
b) SQL-query Answer: a
c) XML document Explanation: For the given expression,
d) All of the mentioned 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
Answer: d
the set of terminal strings that have
Explanation: Parse trees are an alternative
derivations from the start symbol.
representation to derivations and recursive
inferences. There can be several parse trees 155. The language accepted by Push down
for the same string. Automaton:
a) Recursive Language
152. Is the following statement correct?
b) Context free language
Statement: Recursive inference and
c) Linearly Bounded language
derivation are equivalent.
d) All of the mentioned
a) Yes
b) No Answer: b
Explanation: Push down automata accepts
Answer: a
context free language.
Explanation: Yes, they are equivalent. Both
the terminologies represent the two 156. Which of the following the given
approaches of recursive inferencing. language belongs to?
L={ambmcm| m>=1}
153. A->aA| a| b
a) Context free language
The number of steps to form aab:
b) Regular language
a) 2
c) Both (a) and (b)
b) 3
d) None of the mentioned
c) 4
d) 5 Answer: d
Explanation: The given language is neither
Answer: b
accepted by a finite automata or a push
Explanation: A->aA=>aaA=>aab
down automata. Thus, it is neither a context
154. An expression is mentioned as follows. free language nor a regular language.
Figure out number of incorrect notations or
symbols, such that a change in those could

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

157. Choose the correct option: b) Every CFG for L is unambiguous


Statement: There exists two inference c) Every CFG is also regular
approaches: d) None of the mentione
a) Recursive Inference
Answer: a
b) Derivation
Explanation: A CFL L is said to be inherently
a) true ambiguous if every CFG for L is ambiguous.
b) partially true
160. Which of the theorem defines the
c) false
existence of Parikhs theorem?
d) none of the mentioned
a) Parikh‘s theorem
Answer: a b) Jacobi theorem
Explanation: We apply the productions of a c) AF+BG theorem
CFG to infer that certain strings are in a d) None of the mentioned
language of certain variable.
Answer: a
158. Choose the correct option: Explanation: Rohit Parikh in 1961 proved in
Statement 1: Recursive Inference, using his MIT research paper that some context
productions from head to body. free language can only have ambiguous
Statement 2: Derivations, using productions grammars.
from body to head.
161. The most suitable data structure used
a) Statement 1 is true and Statement 2 is
to represent the derivations in compiler:
true
a) Queue
b) Statement 1 and Statement 2, both are
b) Linked List
false
c) Tree
c) Statement 1 is true and Statement 2 is
d) Hash Tables
false
d) Statement 2 is true and Statement 1 is Answer: c
true Explanation: The tree, known as ―Parse
tree‖ when used in a compiler, is the data
Answer: b
structure of choice to represent the source
Explanation: Both the statements are false.
program.
Recursive Inference, using productions from
body to head. Derivations, using 162. Which of the following statement is
productions from head to body. false in context of tree terminology?
a) Root with no children is called a leaf
159. Which of the following statements are
b) A node can have three children
correct for a concept called inherent
c) Root has no parent
ambiguity in CFL?
a) Every CFG for L is ambiguous

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

d) Trees are collection of nodes, with a 165. For the expression E*(E) where * and
parent child relationship brackets are the operation, number of
nodes in the respective parse tree are:
Answer: a
a) 6
Explanation: A node has atmost one parent,
b) 7
drawn above the node, and zero or more
c) 5
children drawn below. Lines connect
d) 2
parents to children. There is one node, one
root, that has no parent; this node appears Answer: b
to be at the top of the tree. Nodes with no Explanation:
children are called leaves. Nodes that are
not leaves are called interior nodes.

163. In which order are the children of any


node ordered?
a) From the left
b) From the right
c) Arbitrarily 166. The number of leaves in a parse tree
d) None of the mentioned with expression E*(E) where * and () are
Answer: a operators
a) 5
Explanation: The children of a node are
b) 2
ordered from the left and drawn so. If N is
c) 4
to the left of node M, then all the
descendents of N are considered to be to d) 3
the left of all the descendents of M. Answer: a
Explanation:
164. Which among the following is the root
of the parse tree?
a) Production P
b) Terminal T
c) Variable V
d) Starting Variable S

Answer: d
Explanation: The root is labelled by the start
symbol. All the leaves are either labelled by 167. Which of the following does the given
a a terminal or with e. parse tree correspond to?

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

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.

170. Grammar is checked by which


component of compiler
a) Scanner
b) Parser
c) Semantic Analyzer
a) P->1100 d) None of the mentioned
b) P->0110
Answer: Parser or syntax analyzer is the one
c) P->1100ε
responsible for checking the grammar and
d) P->0101
reporting errors. In this phase, parse tree is
Answer: b generated and syntax is analyzed.
Explanation: The following is a parse tree
171. A symbol X is if there exists :
for the production 0110 over {0,1}*.
S->* aXb
168. A grammar with more than one parse a) reachable
tree is called: b) generating
a) Unambiguous c) context free
b) Ambiguous d) none of the mentioned
c) Regular
Answer: a
d) None of the mentioned
Explanation: A symbol X is generating if
Answer: b there exists : X->*w for some w that
Explanation: A context free grammar G is belongs to T*.
ambiguous if there is at least one string in Also, a symbol can never be context free.
L(G) having two or more distinct derivation
172. A symbol X is called to be useful if and
trees or equivalently, two or more distinct
only if its is:
leftmost derivations.
a) generating
169. is the acyclic graphical b) reachable
representation of a grammar.

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

c) both generating and reachable a) true


d) none of the mentioned b) false

Answer: c Answer: a
Explanation: For a symbol X to be useful, it Explanation: It is the parse tree theorem
has to be both reachable and generating i.e. which states:
S->* aXb -> * w where w belongs to T*. Given: Suppose we have a parse tree for a
string w, according to a CNF grammar,
173. Which of the following is false for a
G=(V, T, P, S). Let h be the height of the
grammar G in Chomsky Normal Form:
parse tree. Now, Implication: |w|<=2h-1.
a) G has no useless symbols
b) G has no unit productions 176. If |w|>=2h, then its parse tree‘s height
c) G has no epsilon productions is at least
d) None of the mentioned a) h
b) h+1
Answer: d
c) h-1
Explanation: G, a CFG is said to be in
d) 2h
Chomsky normal form if all its productions
are in one of the following form: Answer: b
A->BC or A->a Explanation: It is the basic implication of
Parse tree theorem (assuming CNF). If the
174. Given Checklist:
height of the parse tree is h, then |w| <=2h-
a) G has no useless symbols
1.
b) G has no unit productions
c) G has no epsilon productions 177. If w belongs to L(G), for some CFG,
d) Normal form for production is violated then w has a parse tree, which tell us the
Is it possible for the grammar G to be in CNF structure of w.
with the following checklisy ? a) semantic
a) Yes b) syntactic
b) No c) lexical
d) all of the mentioned
Answer: b
Explanation: The grammar is not in CNF if it Answer: b
violates the normal form of the productions Explanation: A parse tree or concrete
which is strictly restricted. syntactic tree is an ordered, rooted tree
that represents the syntactic structure of a
175. State true or false:
string according to some context free
Statement: A CNF parse tree‘s string yield
grammar.
(w) can no longer be 2h-1.

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

178. Which of the following are distinct to 181. To derive a string using the production
parse trees? rules of a given grammar, we use:
a) abstract parse trees a) Scanning
b) sentence diagrams b) Parsing
c) both abstract parse trees and sentence c) Derivation
diagrams d) All of the mentioned
d) none of the mentioned
Answer: b
Answer: c Explanation: Parsing is required to check
Explanation: Both of the mentioned are the acceptability of a string. Further, comes
different from parse trees. Sentence the syntactical phase which is taken care by
diagrams are pictorial representations of other phases of compiler.
grammatical structure of a sentence.
182. Which of the following parser reaches
179. Choose the correct option: the root symbol of the tree at last?
Statement: Unambiguity is the ideal a) Top down parser
structure of a language. b) Bottom up parser
a) true c) TOP down and Bottom up parser
b) partially true d) None of the mentioned
c) false
Answer: b
d) cant be said
Explanation: Bottom up parser starts from
Answer: a the bottom with the string and comes up to
Explanation: Ideally, there should be only the start symbolusing a parse tree or a
one parse tree for each string, i.e. the derivation tree.
language should be unambiguous.
183. Left corner parsing methof uses which
180. Is the given statement correct? of the following?
Statement: The mere existence of several a) Top down parser
derivations is not an issue, its is the b) Bottom up parser
existence of several parse trees that ruins a c) TOP down and Bottom up parser
grammar. d) None of the mentioned
a) Yes
Answer: c
b) No
Explanation: It is a hybrid method which
Answer: a works bottom up along the left edges of
Explanation: It is also true that multiple each subtree, and top down on the rest of
leftmost or rightmost derivations do cause the parse tree.
ambiguity. Unfortunately, it is not possible
to remove the ambiguity always.

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

184. Which of the following parser functions instead of tables. It is a simplified


performs top down parsing? version of canonical left to right parser.
a) LALR parser
187. LALR in LALR parser stands for:
b) LL parser
a) Left aligned left right parser
c) Recursive Accent parser
b) Look ahead left to right parser
d) None of the mentioned
c) Language Argument left to right parser
Answer: b d) None of the mentioned
Explanation: Bottom up parsing is done by
Answer:
shift reduce parsers like LALR parsers,
Explanation: LALR stands for Look ahead left
Operator precedence parsers, simple
to right parsers. It has more language
precedence parsers, etc.
recognition power than LR(0) parser.
185. Which of the following is true for shift
188. Which of the following can be a LALR
reduce parsers?
parser generator?
a) Scans and parses the input in one
a) YACC
forward pass over the text, without any
b) GNU Bison
backup.
c) YACC and GNU Bison
b) A shift command advances in the input
d) None of the mentioned
stream by one symbol
c) LALR parser Answer: c
d) All of the mentioned Explanation: YACC is a computer code for
UNIX operating system which generates a
Answer: d
LALR parser. On the other hand GNU Bison
Explanation: The mentioned are the correct
or Bison can generate LALR and GLR
and proper functions of a shift reduce
parsers.
parsers. The parsing methods are most
commonly used for parsing programming 189. Which of the following parsers do not
languages, etc. relate to Bottom up parsing?
a) LL parser
186. State true or false:
b) Recursive descent parser
Statement: LALR parsers uses tables rather
c) Earley parsers
than mutually recursive functions.
d) All of the mentioned
a) true
b) false Answer: d
Explanation: All the following mentioned
Answer: b
are top down parsers and begin their
Explanation: It is exactly the opposite case
operation from the starting symbol.
where LALR parsers uses mutually recursive

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

190. Which of the following is true for a the operation is always performed on the
predictive parser? top element of the stack.
a) Recursive Descent parser
194. Which of the following allows stacked
b) no backtracking
values to be sub-stacks rather than just
c) Recursive Descent parser and no
finite symbols?
backtracking
a) Push Down Automaton
d) None of the mentioned
b) Turing Machine
Answer: c c) Nested Stack Automaton
Explanation: Predictive parsing is possible d) None of the mentioned
only for the class of LL-grammars, which are
Answer: c
the CFG for which there exists some
Explanation: In computational theory, a
positive integer k that allows a recursive
nested stack automaton is a finite
descent parser to decide which production
automaton which makes use of stack
to use by examining only the next k tokens
containing data which can be additional
of input.
stacks.
191. A push down automaton employs
195. A non deterministic two way, nested
data structure.
stack automaton has n-tuple definition.
a) Queue
State the value of n.
b) Linked List
a) 5
c) Hash Table
b) 8
d) Stack
c) 4
Answer: d d) 10
Explanation: A push down automata uses a
Answer: d
stack to carry out its operations. They are
Explanation: The 10-tuple can be stated as:
more capable than the finite automatons
NSA= ‹Q,Σ,Γ,δ,q0,Z0,F,[,],]›.
but less than the turing model.
196. Push down automata accepts
193. State true or false:
languages.
Statement: The operations of PDA never
a) Type 3
work on elements, other than the top.
b) Type 2
a) true
c) Type 1
b) false
d) Type 0
Answer: a
Explanation: The term pushdown refers to
Answer: b
the fact that the elements are pushed down
Explanation: Push down automata is for
in the stack and as per the LIFO principle,

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

Context free languages and they are termed Answer: a, d


as Type 2 languages according to Chomsky Explanation: Push and pop are the
hierarchy. operations we perform to operate a stack. A
stack follows the LIFO principle, which
197. The class of languages not accepted by
states its rule as: Last In First Out.
non deterministic, nonerasing stack
automata is 200. A string is accepted by a PDA when
a) NSPACE(n2) a) Stack is empty
b) NL b) Acceptance state
c) CSL c) Both (a) and (b)
d) All of the mentioned d) None of the mentioned

Answer: d Answer: c
Explanation: NSPACE or non deterministic Explanation: When we reach the
space is the computational resource acceptance state and find the stack to be
describing the memory space for a non empty, we say, the string has been
deterministic turing machine. accepted by the push down automata.

198. A push down automaton with only 201. If two sets, R and T has no elements in
symbol allowed on the stack along with common i.e. RÇT=Æ, then the sets are
fixed symbol. called
a) Embedded PDA a) Complement
b) Nested Stack automata b) Union
c) DPDA c) Disjoint
d) Counter Automaton d) Connected

Answer: d Answer: c
Explanation: This class of automata can Explanation: Two sets are called disjoint if
recognize a set of context free languages they have no elements in common i.e.
like {anbn|n belongs to N} RÇT=Æ.

199. Which of the operations are eligible in 202. Which among the following is not a
PDA? part of the Context free grammar tuple?
a) Push a) End symbol
b) Delete b) Start symbol
c) Insert c) Variable
d) Pop d) Production

Answer: a
Explanation: The tuple definition of context

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

free grammar is: (V, T, P, S) where V=set of operations. Turing machines use Queue for
variables, T=set of terminals, P=production, the same.
S= Starting Variable.
206. Which of the following automata takes
203. A context free grammar is a queue as an auxiliary storage?
a) Finite automata
a) English grammar b) Push down automata
b) Regular grammar c) Turing machine
c) Context sensitive grammar d) All of the mentioned
d) None of the mentioned
Answer: c
Answer: c Explanation: Pushdown Automaton uses
Explanation: Context free grammar is the stack as an auxiliary storage for its
set which belongs to the set of context free operations. Turing machines use Queue for
grammar. Similarly, Regular grammar is a the same.
set which belongs to the the set of Context
free grammar. 207. A context free grammar can be
recognized by
204. The closure property of context free a) Push down automata
grammar includes : b) 2 way linearly bounded automata
a) Kleene c) Both (a) and (b)
b) Concatenation d) None of the mentioned
c) Union
d) All of the mentioned Answer: c
Answer: d Explanation: A linearly bounded automata is
Explanation: Context free grammars are a restricted non deterministic turing
closed under kleene operation, union and machine which is capable of accepting ant
concatenation too. context free grammar.

205. Which of the following automata takes 208. A null production can be referred to as:
stack as auxiliary storage? a) String
a) Finite automata b) Symbol
b) Push down automata c) Word
c) Turing machine d) All of the mentioned
d) All of the mentioned Answer: a
Answer: b Explanation: Null production is always taken
Explanation: Pushdown Automaton uses as a string in computational theory.
stack as an auxiliary storage for its 209. NPDA stands for
a) Non-Deterministic Push Down Automata

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

b) Null-Push Down Automata is a useless symbol and thus, can be


c) Nested Push Down Automata eliminated.
d) All of the mentioned
212. The format: A->aB refers to which of
Answer: a the following?
Explanation: NPDA stands for non- a) Chomsky Normal Form
deterministic push down automata whereas b) Greibach Normal Form
DPDA stands for deterministic push down c) Backus Naur Form
automata. d) None of the mentioned

210. Suppose A->xBz and B->y, then the Answer: b


simplified grammar would be: Explanation: A context free grammar is in
a) A->xyz Greibach Normal Form if the right hand
b) A->xBz|xyz sides of all the production rules start with a
c) A->xBz|B|y terminal, optionally followed by some
d) none of the mentioned variables.

Answer: a 213. Which of the following does not have


Explanation: For the first step, substitute B left recursions?
in first production as it only produces a) Chomsky Normal Form
terminal and remove B production as it has b) Greibach Normal Form
already been utilized. c) Backus Naur Form
We get A->xBz|xyz and now, as B has no d) All of the mentioned
production, we eliminate the terms which
Answer: b
hold the variable B, thus the answer remain
Explanation: The normal form is of the
A->xyz.
format:
211. Given Grammar: S->A, A->aA, A->e, B- A->aB where the right hand side production
>bA tends to begin with a terminal symbo, thus
Which among the following productions are having no left recursions.
Useless productions?
214. Every grammar in Chomsky Normal
a) S->A
Form is:
b) A->aA
a) regular
c) A->e
b) context sensitive
d) B->bA
c) context free
Answer: d d) all of the mentioned
Explanation: Some derivations are not
Answer: c
reachable from the starting variable. As B is
Explanation: Conversely, every context frr
not reachable from the starting variable, it

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

grammar can be converted into Chomsky Answer: a


Normal form and to other forms. Explanation: We can eliminate the options
on the basis of the format we are aware of:
215. Which of the production rule can be
A->BC, B->b and so on.
accepted by Chomsky grammar?
a) A->BC 218. Let G be a grammar. When the
b) A->a production in G satisfy certain restrictions,
c) S->e then G is said to be in .
d) All of the mentioned a) restricted form
b) parsed form
Answer: d
c) normal form
Explanation: in CNF, the production rules
d) all of the mentioned
are of the form:
A->BC Answer: c
A-> a Explanation: When the production in G
S->e satisfy certain restrictions, then G is said to
be in ‗normal form‘.
216. Given grammar G:
(1) S->AS 219. Let G be a grammar: S->AB|e, A->a, B-
(2) S->AAS >b
(3) A->SA Is the given grammar in CNF?
(4) A->aa a) Yes
Which of the following productions denies b) No
the format of Chomsky Normal Form?
Answer: a
a) 2,4
Explanation: e is allowed in CNF only if the
b) 1,3
starting variable does not occur on the right
c) 1, 2, 3, 4
hand side of the derivation.
d) 2, 3, 4
220. Which of the following is called Bar-
Answer: a
Hillel lemma?
Explanation: The correct format: A->BC, A-
a) Pumping lemma for regular language
>a, X->e.
b) Pumping lemma for context free
217. Which of the following grammars are languages
in Chomsky Normal Form: c) Pumping lemma for context sensitive
a) S->AB|BC|CD, A->0, B->1, C->2, D->3 languages
b) S->AB, S->BCA|0|1|2|3 d) None of the mentioned
c) S->ABa, A->aab, B->Ac
Answer: b
d) All of the mentioned
Explanation: In automata theory, the

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

pumping lemma for context free languages, than 2p leaf nodes, and therefore its height
also kmown as the Bar-Hillel lemma, is >p+1).
represents a property of all context free
223. Which of the following gives a positive
languages.
result to the pumping lemma restrictions
221. Which of the expressions correctly is and requirements?
an requirement of the pumping lemma for a) {aibici|i>=0}
the context free languages? b) {0i1i|i>=0}
a) uvnwxny c) {ss|s∈ {a,b}*}
b) uvnwnxny d) None of the mentioned
c) uv2nwx2ny
Answer: b
d) All of the mentioned
Explanation: A positive result to the
Answer: b pumping lemma shows that the language is
Explanation: Let L be a CFL. Then there is an a CFL and ist contradiction or negative
integer n so that for any u that belong to result shows that the given language is not
language L satisfying |t| >=n, there are a Context Free language.
strings u, v, w, x, y and z satisfying
224. Using pumping lemma, which of the
t=uvwxy
|vx|>0 following cannot be proved as ‗not a CFL‘?
n n a) {aibici|i>=0}
|vwx|<=n For any m>=0, uv wx y ∈ L
b) {ss|s∈ {a,b}*}
222.Let L be a CFL. Then there is an integer c) The set legal C programs
n so that for any u that belong to language L d) None of the mentioned
satisfying
Answer: d
|t|>=n, there are strings u, v, w, x, y and z
Explanation: There are few rules in C that
satisfying
are context dependent. For example,
t=uvwxy.
declaration of a variable before it can be
Let p be the number of variables in CNF
used.
form of the context free grammar. The
value of n in terms of p : 225. The context free languages are closed
a) 2p under:
b) 2p a) Intersection
c) 2p+1 b) Complement
d) p2 c) Kleene
d) None of the mentioned
Answer: c
Explanation: This inequation has been Answer: c
derived from derivation tree for t which Explanation: Context free languages are
must have height at least p+2(It has more

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

closed under the following operation: 228. Which of the following is incorrect?
union, kleene and concatenation. For There exists algorithms to decide if:
regular languages, we can add intersection a) String w is in CFL L
and complement to the list. b) CFL L is empty
c) CFL L is infinite
226. Given Grammar G1:
d) All of the mentioned
S->aSb
S->e Answer: d
Grammar G2: Explanation: These properties are termed as
R->cRd decision properties of a CFL and include a
R->e set of problems like infiniteness problem,
If L(G)=L(G1) U L(G2), the number of emptiness problem and membership
productions the new starting variable would problem.
have:
229. If the start symbol is one of those
a) 2
symbols which produce no terminal through
b) 3
any sequence, the CFL is said to be
c) 4
a) nullable
d) 1
b) empty
Answer: a c) eliminated
Explanation: d) none of the mentioned
T->S|R
Answer: b
S->aSb
Explanation: In the process of removing
S->e
useless symbols, if the starting symbol is
R->cRd
also a part, the CFL can be then termed as
R->e
empty; otherwise not.
227. Context free languages are not closed
230. Using the pumping constant n, If there
under:
is a string in the language of length
a) Intersection
between and then the language
b) Intersection with Regular Language
is infite else not.
c) Complement
a) n, 2n-1
d) All of the mentioned
b) 2n, n
Answer: d c) n+1, 3n+6
Explanation: It is a theorem which states d) 0, n+1
that, Context free languages are not closed
Answer: a
under operations like intersection and
Explanation: If there is a string in the
complement.
language of length between n and 2n-1

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

then the language is infite else not. The idea with N = {S}, Σ = {a, b}, P with start symbol S
is essentially the same for regular and rules
languages. S → aSb
S→ε
231. Which of the following is/are CFL not
closed under? 234. There is a linear grammar that
a) Reverse generates a context free grammar
b) Homomorphism a) always
c) Inverse Homomorphism b) never
d) All of the mentioned c) sometimes
d) none of the mentioned
Answer: d
Explanation: CFL is closed under union, Answer: c
kleene and concatenation along with the Explanation: Linear grammar is a subset of
properties reversal,homomorphism and context free grammar which has atmost
inverse homomorphism but not difference one non terminal symbol in the right hand
and intersection. side of the production.Thus, there exists
some languages which are generated by
232. If L1 and L2 are context free languages,
Linear grammars.
L1-L2 are context free:
a) always 235. The following format of grammatical
b) sometimes notation is accepted by which of the
c) never following:
d) none of the mentioned AB->CD
A->BC or
Answer: c
A->B or
Explanation: Context free languages are not
A->a
closed under difference, intersection and
where A, B, C, D are non terminal symbols
complement operations.
and a is a terminal symbol.
233. A is context free a) Greibach Normal Form
grammar with atmost one non terminal in b) Chomsky Nrmal Form
the right handside of the production. c) Kuroda Normal Form
a) linear grammar d) None of the mentioned
b) linear bounded grammar
Answer: c
c) regular grammar
Explanation: Linearly Bounded grammar or
d) none of the mentioned
Kuroda Normal Form allows the following
Answer: a format of grammatical analysis:
Explanation: A simple linear grammar is G AB->CD
A->BC or

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

A->B or Answer: a
A->a Explanation: Given a grammar in GNF and a
derivable string in the grammar with the
236. Every Kuroda Normal form grammar
length n, any top-down parser will halt at
generates
depth n. As the parameter ‗depth‘ is
a) Context free grammar
mentioned, we will use a top-down parser.
b) Context sensitive grammar
Example-LL parser.
c) Unrestricted grammar
d) None of the mentioned 239. Which of the following grammars is
similar to Floyd Normal form?
Answer: b
a) Backus Naur Form
Explanation: Every context sensitive
b) Kuroda Normal Form
grammar which does not produce an empty
c) Greibach Normal Form
string can be generated by a grammar in
d) Chomsky Normal Form
Kuroda Normal form.
Answer: a
237. Which of the following can generate
Explanation: Donald Knuth implied a BNF‖
Unrestricted grammars?
syntax in which all definitions have such a
a) Pentonnen Normal form
form may be said to be in ‖Floyd Normal
b) Floyd Normal form
Form‖.
c) Greibach Normal form
A->B|C
d) None of the mentioned
A->BC
Answer: a A->a
Explanation: Pentonnen Normal form(for
240. Which among the following can parse
Unrestricted grammars) is a special case
a context free grammar?
where there is a slight modification in the
a) top down parser
format of Kuroda Normal form.
b) bottom up parser
AB->AD
c) CYK algorithm
A->BC
d) all of the mentioned
A->a
Answer: d
238. Given a grammar in GNF and a
Explanation: We use certain algorithms to
derivable string in the grammar with the
parse a context free grammar which include
length n, any will halt at depth
the most popular CYK algorithm which
n.
employs the concept of bottom up parsing
a) top-down parser
and dynamic parsing.
b) bottom-up parser
c) multitape turing machine 241. The standard version of CYK algorithm
d) none of the mentioned operates only on context free grammars in

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

the following form: 244. Which of the following is regular?


a) Greibach Normal form a) a100b100
b) Chomsky Normal form b) (a+b)*-{a100b100}
c) Backus Naur form c) Both (a) and (b)
d) All of the mentioned d) None of the mentioned

Answer: b Answer: c
Explanation: It requires the presence of a Explanation: As the language seems to be
context free grammar into Chomsky Normal finite, a dfa can be constructed for the
form to operate. However, every context same, thus is regular.
free grammar can be converted into CNF for
245. Which of the following is not context
keeping the sense of grammar equivalent.
free?
242. Which of the following is not a a) {w: nA=nB=nC}
negative property of Context free b) {a*b*c*}
languages? c) {a100b100}
a) Intersection d) All of the mentioned
b) Complement
Answer: d
c) Both (a) and (b)
Explanation: {a*b*c*} and (c) are regular
d) None of the mentioned
languages while option (a) is not context
Answer: c free language.
Explanation: Context free languages are not
246. Which of the following can be used to
closed under complement and intersection.
prove a language is not context free?
Thus, are called Negative properties.
a) Ardens theorem
243. The intersection of context free b) Power Construction method
language and regular language is c) Regular Closure
d) None of the mentioned
a) regular language
b) context free language Answer: c
c) context sensitive language Explanation: We can use the properties of
d) non of the mentioned regular closure to prove that a language is
not a context free language. Example:
Answer: b Intersection of context free language and
Explanation: If a language L1 is regular and regular language is a context free language.
L2 is a context free language, then L1 Proof by contradiction helps here.
intersection L2 will result into a context free
language. 247. A turing machine is a
a) real machine

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

b) abstract machine goes either into accepting halting state or


c) hypothetical machine rejecting halting state.
d) more than one option is correct
250. ‗a‘ in a-machine is :
Answer: d a) Alan
Explanation: A turing machine is abstract or b) arbitrary
hypothetical machine thought by c) automatic
mathematician Alan Turing in 1936 capable d) None of the mentioned
of simulating any algorithm, however
Answer: c
complicated it is.
Explanation: The turing machine was
248. A turing machine operates over: invented by Alan turing in 1936. He named
a) finite memory tape it as a-machine(automatic machine).
b) infinite memory tape
251. Which of the problems were not
c) depends on the algorithm
answered when the turing machine was
d) none of the mentioned
invented?
Answer: b a) Does a machine exists that can determine
Explanation: The turing machine operates whether any arbitrary machine on its tape is
on an infinite memory tape divided into circular.
cells. The machine positions its head over b) Does a machine exists that can
the cell and reads the symbol. determine whether any arbitrary machine
on its tape is ever prints a symbol
249. Which of the functions are not
c) Hilbert Entscheidungs problem
performed by the turing machine after
d) None of the mentioned
reading a symbol?
a) writes the symbol Answer: d
b) moves the tape one cell left/right Explanation: Invention of turing machine
c) proceeds with next instruction or halts answered a lot of questions which included
d) none of the mentioned problems like decision problem, etc.) . Alan
was able to prove the properties of
Answer: d
computation using such model.
Explanation: After the read head reads the
symbol from the input tape, it performs the 252. A turing machine that is able to
following functions: simulate other turing machines:
a) writes a symbol(some model allow a) Nested Turing machines
symbol erasure/no writing) b) Universal Turing machine
b) moves the tape left or right (some c) Counter machine
models allows no motion) d) None of the mentioned
c) proceeds with subsequent instruction or

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

Answer: b Answer: b
Explanation: A more mathematically Explanation:
oriented definition with the same universal The 7-tuple definition of turing machine: (Q,
nature was introduced by church and turing S, G, d, q0, B, F)
together called the Church-Turing where Q= The finite set of states of finite
thesis(formal theory of computation). control
S= The finite set of input symbols
253. Which of the problems are unsolvable?
G= The complete set of tape symbols
a) Halting problem
d= The transition function
b) Boolean Satisfiability problem
q0= The start state, a member of Q, in
c) Both (a) and (b)
which the finite control is found initially.
d) None of the mentioned
B= The blank symbol
Answer: c F= The set of final or accepting states, a
Explanation: Alan turing proved in 1936 that subset of Q.
a general algorithm to solve the halting
256. If d is not defined on the current state
problem for all possible program-input pairs
and the current tape symbol, then the
cannot exist.
machine
254. Which of the following a turing a) does not halts
machine does not consist of? b) halts
a) input tape c) goes into loop forever
b) head d) none of the mentioned
c) state register
Answer: b
d) none of the mentioned
Explanation: If we reach hA or hR, we say TM
Answer: d halts. Once it has halted, it cannot move
Explanation: A state register is one which further, since d is not defined at any pair
stores the state of the turing machine, one (hA,X) or (hR,X) where hA = accept halting
of the finitely many. Among these is the state and hR = reject halting state.
special start state with which the state
257. Which of the following is not true
register is initialized.
about RASP?
255. The value of n if turing machine is a) Binary search can be performed more
defined using n-tuples: quickly using RASP than a turing machine
a) 6 b) Stores its program in memory external to
b) 7 its state machines instructions
c) 8 c) Has infinite number of distinguishable,
d) 5 unbounded registers
d) Binary search can be performed less

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

quickly using RASP than a turing machine a) Every recursive language is recursively
e) More than two options are incorrect ennumerable
b) Recursively ennumerable language may
Answer: d
not be recursive
Explanation: In theoretical computer
c) Recursive languages may not be
science, the random access stored program(
recursively ennumerable
RASP ) machine model is an abstract
d) None of the mentioned
machine used for the purpose of algorithm
development and algorithm complexity Answer: c
theory. Explanation: Every recursive language is
recursively ennumerable but there exists
258. The class of recursively ennumerable
recursively ennumerable languages that are
language is known as:
not recursive. If L is accepted by a Non
a) Turing Class
deterministic TM T, and every possible
b) Recursive Languages
sequence of moves of T causes it to halt,
c) Universal Languages
then L is recursive.
d) RE
261. Choose the correct option:
Answer: d
Statement: If L1 and L2 are recursively
Explanation: RE or recursively ennumerable
ennumerable languages over S, then the
is only called the class of recursively
following is/are recursively ennumerable.
ennumerable language.
a) L1 U L2
259. A language L is said to be Turing b) L2 ∩ L2
decidable if: c) Both (a) and (b)
a) recursive d) None of the mentioned
b) TM recognizes L
Answer: c
c) TM accepts L
Explanation: Both the union and
d) None of the mentioned
intersection operations preserve the
Answer: a,b property of recursive
Explanation: A language L is recursively ennumerablity(Theorem).
ennumerable if there is a turing machine
262. If L is a recursive language, L‘ is:
that accepts L, and recursive if there is a TM
a) Recursive
that recognizes L.(Sometimes these
b) Recursively Ennumerable
languages are alse called Turing-acceptable
c) Both (a) and (b)
and Turing-decidable respectively).
d) None of the mentioned
260. Which of the following statements are
Answer: c
false?
Explanation: If T is a turing machine

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

recognizing L, we can make it recognize L‘ Answer: d


by interchanging the two outputs. And Explanation:
every recursive language is recursively
ennumerable.

263. Choose the appropriate option:


Statement: If a language L is recursive, it is
closed under the following operations:
a) Union
b) Intersection
265. A Language L may not be accepted by a
c) Complement
Turing Machine if:
d) All of the mentioned
a) It it is recursively ennumerable
Answer: d b) It is recursive
Explanation: The closure property of c) L can be ennumerated by some turing
recursive languages include union, machine
intersection and complement operations. d) None of the mentioned

264. A language L is recursively Answer: b


ennumerable if L=L(M) for some turing Explanation: A language L is recursively
machine M. ennumerable if and only if it can be
ennumerated by some turing machine. A
recursive ennumerable language may or
may not be recursive.

266. Which of the following regular


expression resembles the given diagram?

Which among the following cannot be


among A, B and C?
a) yes w ∈ L
b) no w ∉ L
c) M does not halt w ∉ L
d) None of the mentioned

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

a) {a}*{b}*{a,b} string is tested over a turing machine:


b) {a,b}*{aba} a) enter into accept halting state
c) {a,b}*{bab} b) enter into reject halting state
d) {a,b}*{a}*{b}* c) goes into loop forever

Answer: b 269. d(q,X)=(r,Y,D) where D cannot be:


Explanation: The given diagram is a
transition graph for a turing machine which
accepts the language with the regular
expression {a,b}*{aba}. a) L
b) R
267. The number of states required to c) S
automate the last question i.e. d) None of the mentioned
{a,b}*{aba}{a,b}* using finite automata:
a) 4 Answer: c
b) 3 Explanation: D represents the direction in
c) 5 which automata moves forward as per the
d) 6 queue which surely cannot be a starting
variable.
Answer: a
Explanation: The finite automata can be 270. Which of the following can accept even
represented as: palindrome over {a,b}
a) Push down Automata
b) Turing machine
c) NDFA
d) All of the mentioned

Answer: c
Explanation: A language generating strings
which are palindrome is not regular, thus
cannot b represented using a finite
automaton.
268. The machine accept the string by
entering into hA or it can: 271. A turing machine has
a) explicitly reject x by entering into hR number of states in a CPU.
b) enter into an infinte loop a) finite
c) Both (a) and (b) b) infinte
d) None of the mentioned c) May be finite
d) None of the mentioned
Answer: c
Explanation: Three things can occur when a

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

Answer: a the function of the state of finite control


Explanation: A turing machine has finite and the tape symbol just scanned.
number of states in its CPU. However the
273. A turing machine with several tapes in
states are not small in number. Real
known as:
computer consist of registers which can
a) Multi-tape turing machine
store values (fixed number of bits).
b) Poly-tape turing maching
272. Suppose we have a simple computer c) Universal turing machine
with control unit holding a PC with a 32 bit d) All of the mentioned
address + Arithmetic unit holding one
Answer: a
double length 64 bit Arithmetic Register.
Explanation: A multitape turing machine is
The number of states the finite machine will
an ordinary turing machine with multiple
hold:
tapes. Each tape has its own head to control
a) 2(32*64)
the read and write.
b) 296
c) 96 274. A multitape turing machine is
d) 32 powerful than a single tape turing
machine.
Answer: b
a) more
Explanation: According to the statistics of
b) less
the question, we will have a finite machine
c) equal
with 2^96 states.
d) none of the mentioned
273. In one move a turing machine will:
Answer: a
Explanation: The multitape turing machine
model seems much powerful than the
single tape model, but any multi tape
machine, no matter how many tapes, can
be simulated by single taped TM.

275. In what ratio, more computation time


is needed to simulate multitape turing
a) Change a state machines using single tape turing
b) Write a tape symbol in the cell scanned machines?
c) Move the tape head left or right a) doubly
d) All of the mentioned b) triple
c) quadratically
Answer: d d) none of the mentioned
Explanation: A move of a turing machine is

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

Answer: c Answer: d
Explanation: Thus, multitape turing Explanation: A turing machine can have
machines cannot calculate any more many applications like : Enumerator (A
functions than single tape machines. turing machine with an output printer),
function computer, etc.
276. State true or false:
Statement: Multitape turing machine have 279. State true or false:
multi tapes where each tape is accessed Statement: Turing Machine can change
with one head. symbols on its tape, whereas the FA cannot
a) true change symbols on tape.
b) false a) true
b) false
Answer: b
Explanation: Multitape turing machines do Answer: a
have multiple tapes but they they are Explanation: The following mentioned is the
accessed by separate heads. difference between 2-way FA and TM.
Another instance is that TM has a
277. X is a simple mathematical model of a
read/write tape head while FA doesn‘t.
computer. X has unrestricted and unlimited
memory. X is a FA with R/W head. X can 280. Which of the following cannot be a
have an infinite tape divided into cells, each possibility of a TM while it processes an
cell holding one symbol. input?
Name X? a) Enters accepting state
a) Push Down Automata b) Enters non-accepting state
b) Non deterministic Finite Automata c) Enters infinite loop and never halts
c) Turing machines d) None of the mentioned
d) None of the mentioned
Answer: d
Answer: c Explanation: The following mentioned are
Explanation: Turing machine is known as the only possibilities of operating a string
universal computer. It is denoted by through a turing machine.
M=(Q,Σ,Ґ ,δ ,q0, B,F)
281. Pick the odd one out.
278. Which of the following is/are not an a) Subroutines
application of turing machine? b) Multiple tracks
a) Language Recognization c) Shifting over
b) Computers of functions on non negative d) Recursion
numbers
Answer: d
c) Generating devices
Explanation: Except Recursion, all the other
d) None of the mentioned

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

options are techniques of Turing Machine b) State Equivalence


construction which further includes, c) Universal Turing Machine
Checking off symbols and Storage in finite d) None of the mentioned
control.
Answer: a
282. Fill in the blank with an appropriate Explanation: It is a closely related concept
option. with Turing complete. It says, two
In automata theory, is said to computers P and Q are called equivalent if P
be Computationally Universal if can be used can simulate Q and Q can simulate P.
to simulate any single taped Turing
285. Which of the following technique is
Machine.
used to find whether a natural language isnt
a) Computer‘s instruction set
recursive ennumerable?
b) A programming language
a) Diagonalization
c) Cellular Automaton
b) Recursive Induction
d) All of the mentioned
c) Both (a) and (b)
Answer: d d) None of the mentioned
Explanation: Computationally Universal or
Answer: a
Turing Complete is a set of data
Explanation: To find a non recursively
manipulation rules if it can be used to
ennumerable language, we use the
simulate a single-taped turing machine.
technique of diagonalization.
283. Give a classic example of the concept
286. Diagonalization can be useful in:
of turing complete.
a) To find a non recursively ennumerable
a) lambda calculus
language
b) C++
b) To prove undecidablility of haltig
c) Lisp
problem
d) All of the mentioned
c) Both (a) and (b)
Answer: d d) None of the mentioned
Explanation: Most of the programming
Answer: c
languages, conventional or unconventional
Explanation: Diagonalization is a technique
are turing complete. Functional languages
we use for the following operations:
like Lisp and Haskell are also turing
a) To find a non recursively ennumerable
complete.
language.
284. Let two machines be P and Q. The b) To prove undecidablility of halting
state in which P can simulate Q and Q can problem.
simulate P is called:
a) Turing Equivalence

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

287. Which of the following are undecidable way, decidable problems are recursive
problems? languages.
a) Determining whether two grammars
290. Which of the following are decidable
generate the same language
problems?
b) Determining whether a grammar is
a) Can a particular line of code in a program
ambiguous
ever be executed?
c) Both (a) and (b)
b) Do two given CFG‘s generate the same
d) None of the mentioned
language
Answer: c c) Is a given CFG ambiguous?
Explanation: In contrast we can put up an d) None of the mentioned
algorithm for checking whether two FA‘s
Answer: d
are equivalent and this program can be
Explanation: All of the mentioned problems
implemented as a program.
are undecidable.
288. Which of the following are incorrect
291. Which of the following is true for The
options?
Halting problem?
a) Informally, problem is a yes/no question
a) It is recursively ennumerable
about an infinite set of possible instances
b) It is undecidable
b) Formally, a problem is a language
c) Both (a) and (b)
c) Both (a) and (b)
d) None of the mentioned
d) None of the mentioned
Answer: c
Answer: d
Explanation: Halting problem: Does a given
Explanation: Example: Does a graph G has a
Turing machine M halt on a given input w?
Hamilton cycle?
=>Each undirected graph is an instance of 292. The decision problem is the function
Hamilton cycle problem. from string to
a) char
289. If a problem has an algorithm to
b) int
answer it, we call it
c) boolean
a) decidable
d) none of the mentioned
b) solved
c) recognizable Answer: c
d) none of the mentioned Explanation: The decision problem requires
checking of input (string) has some property
Answer: a
or not. That is a string to boolean
Explanation: An algorithm is a TM that halts
transaction.
on all inputs,accepted or not. Putting other

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

293. A language L is said to be a) Undecidable


if there is a turing machine b) Decidable
M such that L(M)=L and M halts at every c) Non finite
point. d) None of the mentioned
a) Turing acceptable
Answer: b
b) decidable
Explanation: Under decidablity of regular
c) undecidable
language properties we have the following
d) none of the mentioned
lemma which states that A DFA which
Answer: b recognizes an input w is decidable.
Explanation: Decidability refers to the
296. Which among the following are semi
decision problem and existence of a
decidable?
effective method for determining
a) Empty-DFA
membership, and return true and false
b) Rec-NFA
accordingly rather that going into a loop
c) Infinite-DFA
forever.
d) All of the mentioned
294. Which aong the following are
Answer: d
undecidable theories?
Explanation: All are the properties of
a) The first order theory of boolean algebra
regular languages and all are decidable
b) The first order theory of Euclidean
languages.
geomentry
c) The first order theory of hyperbolic 297. The language accepted by a turing
geometry machine is called
d) The first order theory of the natural a) Recursive Ennumerable
number with addition, multiplication, and b) Recursive
equality c) Both (a) and (b)
d) None of the mentioned
Answer: d
Explanation: Tarski and Mostowski in 1949, Answer: c
established that the first order theory of Explanation: The language accepted by
natural numbers with addition, Turing machines are called recursively
multiplication, and equality is an ennumerable (RE), and the subset of RE
undecidable theory. Others mentioned are languages that are accepted by a turing
decidable theories. machine that always halts are called
recursive.
295. Rec-DFA = { | M is a DFA and M
recognizes input w}. 298. Decidable can be taken as a synonym
Fill in the blank: to:
Rec-DFA is

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

a) recursive else rejects. It is better called Turing


b) non recursive decidable language.
c) recognizable
301. The class of recursive language is
d) none of the mentioned
known as:
Answer: a a) R
Explanation: We can refer to languages as b) RC
‗recursive‘ and problems as ‗decidable‘. If a c) RL
language is not recursive , then we call the d) All of the mentioned
problem expressed by that language
Answer: a
undecidable.
Explanation: R is the set of all recursive
299. The problems which have no languages, a class of decision problems
algorithm, regardless of whether or not solvable by turing machines. Although, R is
they are accepted by a turing machine that also used for the class RP.
fails to halts on some input are referred as:
302. Which of the following was not a part
a) Decidable
of Chomsky hierarchy ?
b) Undecidable
a) Context sensitive grammar
c) Computable
b) Unrestricted grammar
d) None of the mentioned
c) Recursive grammar
Answer: b d) None of the mentioned
Explanation: The problems that can be
Answer: c
solved by a turing machine can divided into
Explanation: All recursive languages are
two classes:
recursively enumerable. All regular, context
a) Those that have an algorithm
free and context sensitive languages are
b) Intractable problems: Those that are only
recursive.
solved by a turing machine that may run
forever on inputs they do not accept. 303. According to the rice‘s theorem, If P is
a non trivial property, Lp is :
300. Recursive languages are also known as:
a) infinite
a) decidable
b) decidable
b) undecidable
c) undecidable
c) sometimes decidable
d) none of the mentioned
d) none of the mentioned
Answer: c
Answer: a
Explanation: Rice‘s theorem states that ‗Any
Explanation: A language is recursive if there
non trivial property about the language
exists a turing machine such that it halts i.e.
accepts if the input belongs to the language

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

recognized by a turing machine is are constant, and its complement


undecidable‘. b) The class of indices for computable
functions that are total
304. Fill in the blank with reference to Rice‘s
c) The class of indices for recursively
theorem.
enumerable sets that are cofinite
For any non-trivial property of
d) All of the mentioned
no general or effective method can decide
whether an algorithm computes it with that Answer: d
property. Explanation: According to Rice‘s theorem, if
a) partial functions there exists atleast one computable
b) piecewise functions function in a particular class C of
c) both (a) and (b) computable functions and another
d) none of the mentioned computable function not in C then the
problem deciding whether a particular
Answer: a
program computes a function in C is
Explanation: A property of partial functions
undecidable.
is called trivial if it holds for all partial
computable functions or for none, and an 307. Which of the following statements are
effective decision method is called general undecidable?
if it decides correctly for every algorithm. For a given Turing Machine M,
a) does M halt on an empty input tape
305. Which of the following is incorrect
b) does M halt for anly inputs at all?
according to rice theorem?
c) is L(M) regular? Context free? Turing
Let S be a set of language hat is non trivial:
decidable?
a) there exists a TM that recognizes the
d) all of the mentioned
language in S
b) there exists a TM that recognizes the Answer: d
language not in S Explanation: All of the following mentioned
c) both (a) and (b) are immediate results of Rice‘s theorem
d) none of the mentioned and thus, undecidable.

Answer: c 308. Post Correspondence problem is


Explanation: According to rice theorem, it is a) decidable decision problem
undecidable to determine whether the b) undecidable decision problem
language recognized by an arbitrary turing c) not a decision problem
machine lies in S. d) none of the mentioned

306. Which of the following set of Answer: b


computable functions are decidable? Explanation: Post Correspondence problem
a) The class of computable functions that is an undecidable decision problem that

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

was introduced by Emil Post in 1946. Being 312. If the number of steps required to
simpler than halting problem, it can be used solve a problem is O(nk), then the problem
in proofs of undecidability. is said to be solved in:
a) non-polynomial time
309. State true or false:
b) polynomial time
Statement: The difference between PCP
c) infinite time
and MPCP is that in MPCP, a solution is
d) none of the mentioned
required to start with the first string on
each list. Answer: b
a) true Explanation: Most of the operations like
b) false addition, subtraction, etc as well as
computing functions including powers,
Answer: a
square roots and logarithms can be
Explanation: The MPCP is : Given lists A and
performed in polynomial time. In the given
B of K strings ,say A = w1 ,w2, …wk and B=
question, n is the complexity of the input
x1, x2,…..xk does there exists a sequence of
and k is some non negative integer.
integers i1,i2,…ir such that w1wi1wi2…..wir
= x1xi1xi2…xir? 313. The value of constants like p and e can
be calculated in:
310. PCP stands for?
a) polynomial time
a) Post Correspondence Problem
b) non-polynomial time
b) Post Corresponding Problem
c) cannot be calculated
c) Pre Correspondence problem
d) none of the mentioned
d) None of the mentioned
Answer: a
Answer: a
Explanation: The value of such constants
Explanation: PCP or Post Correspondence
can be calculated using algorithms which
problem is an undecidable decision
have time complexity in terms if O(nk) i.e
problem.
polynomial time.
311. Can a Modified PCP problem be
313. Which of the following cannot be
reduced to PCP?
solved using polynomial time?
a) yes
a) Linear Programming
b) no
b) Greatest common divisor
Answer: a c) Maximum matching
Explanation: Yes, it can be. There exists a d) None of the mentioned
theorem and as well as its proof which
Answer: d
supports the assertion.
Explanation: In graph theory, a matching or
independent edge set in a graph G is a set

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

of edges without common vertices. Given a c) complete problem for complexity class P
graph (V, E), a matching M in G is a set of d) all of the mentioned
pairwise non adjacent edges i.e. no two
Answer: d
edges share a common vertex.
Explanation:
314. The complexity class P consist of all the The notion of P-complete decision problems
decision problems that can be solved by is useful in the analysis of:
using polynomial amount of a) which problems are tough to parallelize
computation time. effectively
b) which problems are difficult to solve in
a) Push Down automata
limited space
b) DFA
c) NDFA 317. What does NP stands for in complexity
d) Deterministic Turing machine classes theory?
a) Non polynomial
Answer: d
b) Non-deterministic polynomial
Explanation: All the decision problems that
c) Both (a) and (b)
can be solved using a Deterministic turing
d) None of the mentioned
machine using polynomial time to compute,
all belong to the complexity class P. Answer: b
Explanation: NP is said to be one of the
315. A generalization of P class can be:
most fundamental complexity classes. NP is
a) PTIME
an acronym for Non deterministic
b) DTIME
polynomial time.
c) NP
d) None of the mentioned 318. The hardest of NP problems can be:
a) NP-complete
Answer: c
b) NP-hard
Explanation: P is a specific case of NP class,
c) P
which is the class of decidable problems
d) None of the mentioned
decidable by a non deterministic turing
machine that runs in polynomial time. Answer: a
Explanation: NP class contains many
316. Which of the following options are
important problems, the hardest of which is
correct with reference to P-complete
NP-complete, whose solution is sufficient to
problems?
deal with any other NP problem in
a) used for the problems which are difficult
polynomial time.
to solve in limited space
b) every problem in P can be reduced to it 319. Travelling sales man problem belongs
using proper reductions to which of the class?

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

a) P problem. It is easier to show a problem NP


b) NP than showing it Np Hard.
c) Linear
322. In terms of NTIME, NP problems are
d) None of the mentioned
the set of decision problems which can be
Answer: b solved using a non deterministic machine in
Explanation: Travelling Salesman Problem: time.
Given an input matrix of distances between a) O(n)
n cities, this problem is to determine if b) O(n1/2)
there is a route visiting all cities with total c) O(nk), k∈ N
distance less than k. d) None of the mentioned

320. State true or false? Answer: c


Statement: If a problem X is in NP and a Explanation: The complexity class NP can be
polynomial time algorithm for X could also defined in terms of NTIME as:
be used to solve problem Y in polynomial NP=O(nk) for k ∈ N.
time, then Y is also in NP.
323. Which of the following can be used to
a) true
define NP complexity class?
b) false
a) Verifier
Answer: a b) Polynomial time
Explanation: This is just a commutative c) Both (a) and (b)
property of NP complexity class where a d) None of the mentioned
problem is said to be in NP if it can be
Answer: c
solved using an algorithm which was used
Explanation: NP can be defined using
to solve another NP problem in polynomial
deterministic turing machines as verifiers.
amount of time.
324. Which of the following are not in NP?
321. A problem which is both and
a) All problems in P
is said to be NP complete.
b) Boolean Satisfiability problems
a) NP, P
c) Integer factorization problem
b) NP, NP hard
d) None of the mentioned
c) P, P complete
d) None of the mentioned Answer: d
Explanation: This is a list of some problems
Answer: a
which are in NP:
Explanation: A problem is said to be NP
a) All problems in P
Hard if an algorithm for solving the problem
b) Decision version of Integer factorization
can be translated from for solving any other
method

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

c) Graph Isomorphism Problem problems that are NP-complete and the set
d) All NP complete problems, etc. is called Karp‘s 21 NP-complete problems.

325. Which of the following does not 328. Which of the following problems were
belong to the closure properties of NP reduced to Knapsack?
class? a) Exact Cover
a) Union b) Max Cut
b) Concatenation c) 0-1 integer programming
c) Reversal d) None of the mentioned
d) Complement
Answer: a
Answer: d Explanation: Exact cover is a decision
Explanation: It is unknown about the problem in computer science to determine
closure property-complement for the if an exact cover exists.
complexity class NP. The question is so
329. An exact cover problem can be
called NP versus co-NP problem.
represented using:
326. Which of the given problems are NP- a) incidence matrix
complete? b) bipartite graph
a) Node cover problems c) both (a) and (b)
b) Directed Hamilton Circuit Problem d) none of the mentioned
c) Both (a) and (b)
Answer: c
d) None of the mentioned
Explanation: The relation ‗contains‘ can be
Answer: c represented using a bipartite graph. The
Explanation: Vertex cover or Node cover vertices of the graph can be divided into
problem, and Hamilton Circuit problem, two disjoint sets, one representing the
both are NP complete type of problems. subset S and the other representing the
elements of P and one edge for each subset
327. Which of the following problems do
in S;each node is included in exactly one of
not belong to Karp‘s 21 NP-complete
the edges forming the cover.
problems?
a) Vertex Cover problems 330. For which of the following, greedy
b) Knapsack algorithm finds a minimal vertex cover in
c) 0-1 integer programming polynomial time?
d) None of the mentioned a) tree graphs
b) bipartite graphs
Answer: d
c) both (a) and (b)
Explanation: There exists a set of 21
d) none of the mentioned

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

Answer: a a) Las Vegas Algorithm


Explanation: For bipartite graphs, Konigs b) Monte Carlo Algorithm
theorem allows the bipartite vertex c) Atlantic City Algorithm
d) None of the mentioned
problem to be solved in polynomial time.

331. All set of polynomial questions which Answer: a


Explanation: The other type of algorithms
can be solved by a turing machine using a
are probabalistic algorithms, which
polynomial amount of space: depending upon the random input, have a
a) PSPACE chance of producing incorrect results or fail
b) NPSPACE to produce a result.
c) EXPSPACE
334. Which of the following are probalistic
d) None of the mentioned
algorithms?
Answer: a a) Las Vegas Algorithm
b) Monte Carlo Algorithm
Explanation: PSPACE is the problem class
c) Atlantic City Algorithm
which contains all set of decision problems d) All of the mentioned
which can be solved using a turing machine
taking polynomial amount of space. Answer: d
Explanation: Monte Carlo algorithms are
332. A randomized algorithm uses random very vast, but only probably correct. On thr
bits as input inorder to achieve a other side, Las Vegas algorithms are always
good performance over all correct, but probably fast.
possible choice of random bits.
a) worst case 335. Which of the following algorithms are
b) best case probably correct as well as fast?
c) average case a) Las Vegas Algorithm
d) none of the mentioned b) Monte Carlo Algorithm
c) Atlantic City Algorithm
Answer: c d) All of the mentioned
Explanation: A randomized algorithm is an
algorithm that employs a degree of Answer: c
randomness as a part of its logic using Explanation: The atlantic city algorithms
random bits as inputs and in hope of which are bounded polynomial time
producing average case good performace. algorithms are probably correct and
probably fast. It is correct more than 75% of
333. Which of the following options match the times.
the given statement:
Statement: The algorithms that use the 336. Prisonner‘s dilemma can be related to
random input to reduce the expected the following:
running time or memory usage, but always a) cooperative behaviour
terminate with a correct result in a b) graph theory
bounded amount of time. c) Both (a) and (b)

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

d) None of the mentioned Carlo Algorithm. If a is fount, the algorithm


succeeds, else the algorith fails. The
Answer: a algorithm doesn not guarantee success but
Explanation: Prisonner‘s dilemma is a the run time is bounded.
standard example of a game analysed in
game theory where rational cooperative 339. Which of the following can be solved in
behaviour is judged on the basis of rewards computer science?
and punishment. a) P=BPP problem
b) NP=co-NP problem
337. State true or false: c) Do one way problems exist?
Statement: A turing machine has the d) All of the mentioned
capability of using randomly ‗generated‘
numbers. Answer: d
a) true Explanation: There exists a list of unsolved
b) false problems in computational theory which
includes many problems including the ones
Answer: a given.
Explanation: Complexity theories models
randomized algorithms as probalistic turing 340. Which of the following can be referred
machines. A probalistic turing machine is a to as applications of Randomized
non deterministic turing machine which algorithm?
randomly chooses between the available a) Quicksort
transitions at each point according to some b) Min Cut
probalistic distribution. c) Verifying Matrix Multiplication
d) All of the mentioned
338. For the given algorithm, find the
probability of finding after k iterations: Answer: d
Explanation: Freivalds algorithm is a
probabalistic randomized algorithm we use
begin to verify matrix multiplication. On the other
i=0 hand, Randomness can be useful in
repeat quicksort. If the algorithm selects pivot
element uniformaly at random, it has a
elements probably high probabilty of finishing the
i=i+1 work in O(nlogn) time regardless of the
until i=k or a is found input.
end
341. Which among the following is smallest
k
a) (1/2) for n=50
b) (1-(1/3))k a) 2n2
c) 1-(1/2)k b) n2+3n+7
d) None of the mentioned
c) n3
Answer: c d) 2n
Explanation: The given is known as Monte

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

Answer: b c) Space(f)
Explanation: d) All of the mentioned
2n2=5000
Answer: d
n2+3n+7=2567
Explanation: Ntime(f): is a set of languages
n3=125000
that can be accepted by a NTM T with non
2n=1.13*1015
deterministic time complexity function t
342. The space complexity of a turing <=f. In all four cases, the machines are
machine is undefined if: allowed to be multitape TM‘s.
a) It is a multitape turing machine
345. A function f is called if
b) If no string of length n causes T to use
there exists a TM T so that for any n and
infinite number of tape squares
any input string of length n, T halts in
c) If some input of length n causes T to loop
exactly f(n) moves.
forever
a) Step function
d) None of the mentioned
b) Step counting function
Answer: c c) Inplace functions
Explanation: If there exists an input string of d) None of the mentioned
length n that causes T to use an infinite
Answer: b
number of tape squares, the space
Explanation: If f is a step counting function,
complexity of the turing machine is
T is a TM halting in f(n) moves where n is
undefined.
the length of input string.
343. In order to reduce the run time of a
346. Let f: N->N be a step counting function.
turing machine:
Then for some constant C, Time(f) is a
a) we can reduce the number of tapes
b) we can increase the number of tapes proper subset of Time( )
a) O(nf)
c) use infinite tapes
b) O(n+f)
d) none of the mentioned
c) O(n2f2)
Answer: One way to reduce the run time d) None of the mentioned
can be to increase the number of tapes.
Answer: c
Sometimes, using two tapes can be used to
Explanation: Using the encoding function, it
avoid back and forth motions altogether.
is possible to show that if the function f is a
344. Which of the following are basic step counting function, then the function
complexity classes for a function f:N->N? Cn2(f(n))2 is the total number of moves
a) Ntime(f) required.
b) Nspace(f)

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

347. Which of the following are valid a) Remove useless variables


membership algorithms? b) Remove unit and epsilon production
a) CYK algorithm c) Create dependency graph for variables
b) Exhaustive search parser d) If there is a loop in the dependency graph
c) Both (a) and (b) the the language is finite else infinite
d) None of the mentioned
Answer: d
Answer: c Explanation: If we are able to detect a loop
Explanation: CYK algorithm is a parsing in the formed dependency graph, then the
algorithm for context free grammars, which language in infinite.
employs bottom up parsing and dynamic
351. State true or false:
programming.
Statement: Every context free language can
348. Which of the following belong to the be generated by a grammar which contains
steps to prove emptiness? no useless non terminals.
a) Remove useless variable a) true
b) Check if a start variable S is useless b) false
c) Both (a) and (b)
Answer: a
d) None of the mentioned
Explanation: At first, we detect useless
Answer: c symbols and discard them. Inorder to find
Explanation: The empty-language question whether a symbol is useless, just make it
can be stated as: For context free grammar the starting symbol and check for
G find if L(G) =f? emptiness.

349. Which of the following is true for CYK 352. Consider the following grammar.
Algorithm?
a) Triangular Table
b) Circular Chart
c) Linked List
d) None of the mentioned
F -> id
Answer: a Consider the following LR (0) items
Explanation: A triangular table is corresponding to the grammar above.
constructed to facilitate the solution of
membership problem using bottom up S -> S .E
parsing and dynamic programming.

350. Which of the following steps are wrong


Given the items above, which two of them
with respect to infiniteness problem? will appear in the same set in the canonical

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

sets-of-items for the grammar? b) 2 * + 3 4


a) (ii) c) 2 3 * 4 +
b) (i) and (iii) d) 2 3 4 + *
c) (iii)
d) None of the mentioned Answer: b
Explanation: Input string 2 ) 3 + 4 S ‖ ER FR
Answer: C idR {print(2)} id)ER {print())} id) F+ER
Explanation: If S -> S): E is in LR (0) then E -> {print(+)}id) id + ER {print(3)} id) id ) id +id
F +: E will also be there because both of So 2 )+ 3 4 are printed.
them has ‗: ‗ before E.
355. Consider the following C code
353. Consider the following grammar: segment.

for for if i # i } } }
R -> S ε
F -> id Which one to the following false?
In the predictive parser table, M, of the a) The code contains loop-in variant
grammar the entries M [S, id] and M [R, $] computation
respectively. b) There is scope of common sub-
a) {S ‖ FR} and {R ‖ ε} expression elimination in this code
b) {S ‖ FR} and {} c) There is scope strength reduction in this
c) {S ‖ FR} and {R ‖ * S} code
d) {F ‖ id} and {R ‖ ε} d) There is scope of dead code elimination
in this code
Answer: a
Explanation: The predictive parser table is Answer: d
given as. Non Terminal) id $ S S ―FR F F ―id R Explanation: All the statements are true
R ―) S R ―! R ―! So at M [ S, id] = { S ‖ FR} M [ except option (There is scope of dead code
R,$] = {R ―!}. elimination in this code ) since there is no
dead code to get eliminated.
354. Consider the following translation
scheme. 356. Which of these is also known as look-
head LR parser?
a) SLR
R -> E{print{‘ ‘); b) LR
R f c) LLR
E -> F + E{print(‘ + ‘); F d) None of the mentioned
F -> (S) id{print(id.value);}
Answer: c
Here id is a taken that represents an integer
and id. value represents the corresponding Explanation: LLR is the look ahead parser.
integer value. For an input ‗2 * 3 + 4‘, this
357. What is the similarity between LR,
translation scheme prints?
a) 2 * 3 + 4 LALR and SLR?

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

a) Use same algorithm, but different parsing deterministic context-free languages in


table guaranteed linear time.
b) Same parsing table, but different
360. Which of the following is incorrect for
algorithm
the actions of A LR-Parser I) shift s ii) reduce
c) Their Parsing tables and algorithm are
A->ß iii) Accept iv) reject?
similar but uses top down approach
a) Only I)
d) Both Parsing tables and algorithm are
b) I) and ii)
different
c) I), ii) and iii)
Answer: a d) I), ii) , iii) and iv)
Explanation: The common grounds of these
Answer: c
3 parser is the algorithm but parsing table is
Explanation: Only reject out of the following
different.
is a correct LR parser action.
358. An LR-parser can detect a syntactic
361. What is terminal table?
error as soon as
a) Contains all constants in the program
a) The parsing starts
b) Is a permanent table of decision rules in
b) It is possible to do so a left-to-right scan
the form of patterns for matching with the
of the input
uniform symbol table to discover syntactic
c) It is possible to do so a right-to-left scan
structure
of the input
c) Consist of a full or partial list of the token
d) Parsing ends
is as they appear in the program created by
Answer: b lexical analysis and used for syntax analysis
Explanation: Error is found when it the and interpretation
input string is scanned. d) Is a permanent table which lists all
keywords and special symbols of the
359. Which of these is true about LR
language in symbolic form
parsing?
a) Is most general non-backtracking shift- Answer: d
reduce parsing Explanation: A permanent database that
b) It is still efficient has entry for each terminal symbols such as
c) Is most general non-backtracking shift- arithmetic operators, keywords,
reduce parsing & It is still efficient punctuation characters such as ‗;‘, ‗,‘etc
d) None of the mentioned Fields: Name of the symbol.

Answer: c 362. Advantage of incorporating the macro-


Explanation: LR parsers are a type of processor into pass 1 is that
bottom-up parsers that efficiently handle a) Many functions have to be implemented
twice

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

b) Functions are combined not necessarily 365. A series of statements explaining how
creating intermediate files as output from the data is to be processed is called
the macro-processor and input to the
assembler a) Assembly
c) More flexibility is provided to the b) Machine
programmer in that he may use all the c) COBOL
features of the assembler in conjunction d) Program
with macros
Answer: d
d) All of the mentioned
Explanation: A program is a sequence of
Answer: d instructions, written to perform a task by
Explanation: A general-purpose macro computer. It requires programs to function,
processor or general purpose pre-processor typically executing the program‘s
is a macro designed primarily for string instructions in a central processor.
manipulation, macro definition.
366. In a single pass assembler, most of the
363. Which of the following is a phase of a forward references can be avoided by
compilation process? putting the restriction
a) Lexical Analysis a) On the number of strings/life reacts
b) Code Generation b) Code segment to be defined after data
c) Lexical Analysis & Code Generation segment
d) None of the mentioned c) On unconditional rump
d) None of the mentioned
Answer: c
Explanation: Lexical analysis and code Answer: b
generation is a phase of compilation Explanation: A single pass assembler scans
process. the program only once and creates the
equivalent binary program.
364. System program such as compiler are
designed so that they are 367. The method which merges the bodies
a) Re-enterable of two loops is?
b) Non reusable a) Loop rolling
c) Serially usable b) Loop jamming
d) None of the mentioned c) Constant folding
d) None of the mentioned
Answer: a
Explanation: Re-enterable is the keyword Answer: b
for compiler being designed. Explanation: In computer science, loop
fusion (or loop jamming) is a compiler

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

optimization and loop transformation which b) Build a literal table and an identifier table
replaces multiple loops with a single one. c) Build a uniform symbol table
d) Parse the source program into the basic
368. Assembly code data base is associated
elements or tokens of the language
with
a) Code is converted into assembly Answer: a
b) Table of rules in the form of patterns for Explanation: In this phase symbol table is
matching with the uniform symbol table to created by the compiler which contains the
discover syntactic structure list of lexemes or tokens.
c) All of the mentioned
371. Which is not true about syntax and
d) None of the mentioned
semantic parts of a computer language?
Answer: a a) Semantics is checked mechanically by a
Explanation: An assembly language is a low- computer
level programming language for a b) Semantics is the responsibility of the
computer, or other programmable device, programmer
in which there is a very strong (generally c) All of the mentioned
one-to-one) correspondence between the d) None of the mentioned
language and the architecture‘s machine
Answer: d
code instructions.
Explanation: Both in terms of semantics is
369. The process manager has to keep track not true.
of
372. Which of the following statement is
a) Status of each program
true?
b) Information to a programmer using the
a) SLR powerful than LALR
system
b) LALR powerful than Canonical LR parser
c) Status of each program & Information to
c) Canonical LR powerful than LALR parser
a programmer using the system
d) The parsers SLR= Canonical LR=LALR
d) None of the mentioned
Answer: c
Answer: c
Explanation: LR > LALR > SLR In terms of the
Explanation: Process manager keep track of
parser.
the status and info about the program.
373. Which of the following features cannot
370. What is the function of the syntax
be captured by CFG?
phase?
a) Syntax of if-then-else statements
a) recognize the language and to cal the
b) Syntax of recursive procedures
appropriate action routines that will
c) A variable is declared before its use
generate the intermediate form or matrix
d) Matching nested parenthesis
for these constructs

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

Answer: d procedures are not available for dynamic


Explanation: It is because, it is equivalent to linking
recognizing us, where the first w is the d) Cryptographic procedures are not
declaration and the second is its use, we are available for dynamic linking
not a CFG.
Answer: d
374. In which of the following no Explanation: Required by the program are
information hiding is done? linked during run time.
a) Compile prig 1, prig 2
377. Which of the following statements is
b) Run test, prog
FALSE?
c) Load R1, A
a) In up-typed languages, values do not
d) 001001000010101
have any types & Dynamic languages have
Answer: d no variables types
Explanation: The entire binary symbol gives b) In up-typed languages, values do not
information. have any types
c) Dynamic languages have no variables
375. The identification of common sub-
types
expression and replacement of run-time
d) None of the mentioned
computations by compile-time
computations is _ Answer: c
a) Local optimization Explanation: They have dynamically
b) Loop optimization changing types.
c) Constant folding
378. What is grammar?
d) Data flow analysis
S -> C C
Answer: c
Explanation: Constant folding is the process C -> eC | d
of recognizing and evaluating constant
expressions at compile time rather than a) LL (1)
computing them at runtime. Terms in b) SLR (1) but not LL (1)
constant expressions are typically simple c) LALR (1) but not SLR (1)
literals they may also be variables whose d) LR (1) but not LALR (1)
values are assigned at compile time.
Answer: c
376. Dynamic linking can cause security Explanation: The grammar is CLR and can be
concerns because reduced to LALR.
a) Security is dynamic
379. The 3-address code sequence
b) None of the mentioned
generated by which definition?
c) Security is dynamic & Cryptographic

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

S -> id: = E " Answer: a


Explanation: LL(1) parsers can recognize the
newtemp ();
regular grammars also LL(1) is subset of
gen(t . place . place;); .place t} " LR(1) or CLR grammar so it also recognizes
regular sets. So both accept regular
.place .place;} grammar.
For the statement ‗X: = Y + Z ‘, 382. In a simplified computer the
instructions are:
a) X = Y + Z
b) t1 = Y + Z; X t1 OP R j, Ri − Performs Rj OP Ri and stores the
c) t1 = Y; t2 = t1 + Z; X = t2 result in register Ri
d) t1 = Y; t2 = Z; t3 + t2; X = t3
OP m, Ri − Performs val OP Ri abd stores the
Answer: d result in Ri. value denotes the content of
Explanation: In 3-address code we use memory location m.
temporary variables.
MCVm, Ri −Moves the content off memory
380. If the programming language uses loction m to register Ri.
static scoping and call by need parameter
passing mechanism, the values printed will MCVm, Ri, m −Moves the content of
be? register Ri to memory location m.
a) 115, 220
The computer has only two registers, and
b) 25, 220
OP is either ADD or SUB. Consider the
c) 25, 15
following basic block:
d) 115, 105
t1 = a + b
Answer: d
Explanation: So i = 100 & j = 5 P (i + j) = P t2 = c + d
(100 + 5) = P(105) So x = 105 x + 10 = 105 +
t3 = e − t2
10 = 115 So 115 & 105 will be printed.
t4 = t 1 − t2
381. Consider the following two
statements: Assume that all operands are initially in
P: Every regular grammar is LL(1) memory. The final value of the computation
Q: Every regular set has LR(1) grammar should be in memory. What is the minimum
Which of the following is TRUE? number of MOV instructions in the code
a) Both P and Q are true generated for this basic block?
b) P is true and Q is false a) 2
c) P is false and Q is true b) 3
d) Both P and Q are false

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

c) 5 A->bAA B->aBB
d) 6
a) 1
Answer: b b) 2
Explanation: The operation sequence would c) 3
be d) 4
MOV a, R1
Answer: b
ADD b , R1 {R 1 = t1
Explanation: For the derivation two trees
MOV c , R2
are possible So due to ambiguity 2 trees are
ADD d, R2 {R 2 = t2
possible.
SUB e , R2 {t 3 = e − R 2 = R2
SUB R 1, R2 {R 2 = t4 385. Which of the following describes a
MOV R 2, t4 {finally in memory handle (as applicable to LR-parsing)
Totally no. of move operation is 3. appropriately?
a) It is the position in a sentential form
383. Which of the following strings is
where the next shift or reduce operation
generated by the grammar?
will occur
S->bA S->aB b) It is a non-terminal whose production will
be used for reduction in the next step
A->a B->b
c) It is a production that may be used for
A->aS B->bS reduction in a future step along with a
position in the sentential form where the
A->bAA B->aBB next shift or reduce operation will occur.
d) It is the production p that will be used for
a) aaaabb
reduction in the next step along with a
b) aabbbb
position in the sentential form where the
c) aabbab
right hand side of the production may be
d) abbbba
found
Answer: c
Answer: d
Explanation: aabbab S ‖ aB ‖ aaBB ‖ aabSB ‖
Explanation: Handles are the part of
aabbAB ‖ aabbab
sentential form, & they are identified as the
384. How many derivation trees are there? right side of any given production which will
be used for reduction in the next step.
S->bA S->aB
386. Which languages necessarily need
A->a B->b
heap allocation in the runtime
A->aS B->bS environment?
a) Those that support recursion

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

b) Those that use dynamic scoping 389. In Two pass assembler the object code
c) Allow dynamic data structure generation is done during the
d) Those that use global variables
a) Second pass
Answer: c
b) First pass
Explanation: E.g.: Heap.
c) Zeroth pass
387. Given the language L-{ab, aa, baa}, d) Not done by assembler
which of the following strings are in LG?
Answer:a
1) abaabaaabaa Explanation: On the second pass, the
assembler:
2) aaaabaaaa • source statements into machine code
• error messages, if error has occurred.
3) baaaaabaaaab
390. Pick the machine independent phase
4) baaaaabaa
of the compiler.
a) 1,2 and 3 a) Syntax analysis
b) 2,3 and 4 b) Code generation
c) 1,2 and 4 c) Lexical analysis
d) 1,3 and 4 d) All of the mentioned

Answer: c Answer: d
Explanation: Generates strings like Explanation: Machine independent phases
aaaabaaaa are Lexical analysis, Syntax analysis,
baaaaabaa Semantic analysis, Intermediate code
generation and sometime code
388. In a two pass assembler, adding literals
optimization.
to literal table and address resolution of
local symbols are done using? 391. The load instruction is mostly used to
a) First pass and second respectively designate a transfer from memory to a
b) Both second pass processor register known as
c) Second pass and first respectively a) Accumulator
d) Both first pass b) Instruction Register
c) Program counter
Answer: d
d) Memory address Register
Explanation: A two pass assembler does
two passes over the source file (the second Answer: a
pass can be over a file generated in the first Explanation: Accumulator is the process
pass). register.

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

392. A group of bits that tell the computer Answer: a


to perform a specific operation is known as Explanation: MIMD stands for multiple
instructions multiple data.
a) Instruction code
b) Micro-operation 396. The instruction ‗ORG O‘ is a
c) Accumulator a) Machine Instruction
d) Register b) Pseudo instruction
c) High level instruction
Answer: a d) Memory instruction
Explanation: Instruction code is the set of
specific tasks to be performed. Answer: b
Explanation: It is a pseudo instruction.
393. The time interval between adjacent
bits is called the 397. ‗Aging registers‘ are
a) Word-time a) Counters which indicate how long ago
b) Bit-time their associated pages have been
c) Turnaround time Referenced
d) Slice time b) Registers which keep track of when the
program was last accessed
Answer: b c) Counters to keep track of last accessed
Explanation: Bit time is the interval time instruction
here. d) Counters to keep track of the latest data
structures referred
394. A k-bit field can specify any one of
Answer: a
a) 3k registers Explanation: This is known as aging.
b) 2k registers
c) K2 registers 398. Memory unit accessed by content is
d) K3 registers called
a) Read only memory
Answer: b b) Programmable Memory
Explanation: 2k is the answer. c) Virtual Memory
d) Associative Memory
395. MIMD stands for
a) Multiple instruction multiple data Answer: d
b) Multiple instruction memory data Explanation: Associative Emory is accessed
c) Memory instruction multiple data by content.
d) Multiple information memory data
399. The main memory in a Personal
Computer (PC) is made of
a) Cache memory

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

b) Static RAM 403. Logic X-OR operation of (4ACO) H &


c) Dynamic Ram (B53F) H results
d) Cache memory & RAM a) AACB
b) 0000
Answer: d
c) FFFF
Explanation: It is made up of cache memory
d) ABCD
and RAM.
Answer: c
400. Cache memory works on the principle
Explanation: Xoring the two operands we
of
get FFFF.
a) Locality of data .
b) Locality of memory 403. Generally Dynamic RAM is used as
c) Locality of reference main memory in a computer system as it
d) Locality of reference & memory
a) Consumes less power
Answer: c
b) Has higher speed
Explanation: Cache works on Locality of
c) Has lower cell density
reference.
d) Needs refreshing circuitry
401. An n-bit microprocessor has
Answer: b
Explanation: Because of higher speed it is
a) n-bit program counter
Dynamic.
b) n-bit address register
c) n-bit ALU 404. Write Through technique is used in
d) n-bit instruction register which memory for updating the data

Answer: d
a) Virtual memory
Explanation: N bit microprocessor has bit
b) Main memory
instruction register.
c) Auxiliary memory
402. When CPU is executing a Program that d) Cache memory
is part of the Operating System, it is said to
Answer: d
be in
Explanation: The answer is cache memory.
a) Interrupt mode
b) System mode 405. Cache memory acts between
c) Half mode
d) Simplex mode a) CPU and RAM
b) RAM and ROM
Answer: b
c) CPU and Hard Disk
Explanation: It is in System Mode.
d) None of the mentioned

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

Answer: a b) (001011111010 0000 1100)2


Explanation: It acts between CPU and RAM. c) (195 084)10 & (001011111010 0000
1100)2
406. The idea of cache memory is based
d) None of the mentioned

a) On the property of locality of reference Answer: b


b) On the heuristic 90-10 rule Explanation: It is equivalent to
c) On the fact that references generally (001011111010 0000 1100)2.
tend to cluster
d) All of the mentioned 410. The circuit used to store one bit of
data is known as
Answer: a a) Register
Explanation: Cache memory is based on the b) Encoder
locality of references. c) Decoder
d) Flip Flop
407. Which of the following is not a
weighted code? Answer: d
a) Decimal Number system Explanation: 1 bit circuit is known as Flip
b) Excess 3-cod Flop.
c) Binary number System
d) None of the mentioned 411. Computers use addressing mode
techniques for
Answer: b a) Giving programming versatility to the
Explanation: Excess 3 is not a weighted user by providing facilities as pointers to
code. memory counters for loop control
b) To reduce number of bits in the field of
408. The average time required to reach a
instruction
storage location in memory and obtain its
c) Specifying rules for modifying or
contents is called the
interpreting address field of the instruction
a) Seek time
d) All of the mentioned
b) Turnaround time
c) Access time Answer: d
d) Transfer time Explanation: All of these are addressing
mode techniques.
Answer: c
Explanation: Times used to access the 412. Which of the following derivations
contents. does a top-down parser use while parsing
an input string?
409. (2FAOC) 16 is equivalent to
a) Leftmost derivation
b) Leftmost derivation in reverse
a) (195 084)10

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

c) Rightmost derivation 415. Which of the following grammar rules


d) Rightmost derivation in reverse violate the requirements of an operator
grammar?
Answer: a
Explanation: In top down parser takes input (i) P -> QR
from Left to right constructing leftmost
(ii) P -> QsR
derivation of the sentence.
(iii) P -> ε
413. The process of assigning load
addresses to the various parts of the (iV) P -> QtRr
program and adjusting the code and data in
the program to reflect the assigned a) (i) only
addresses is called? b) (i) and (iii) only
a) Assembly c) (ii) and (iii) only
b) Parsing d) (iii) and (iv) only
c) Relocation
Answer: b
d) Symbol resolute
Explanation: An operator precedence parser
Answer: c is a bottom-up parser that interprets an
Explanation: Relocation is the process of operator-precedence grammar.
replacing symbolic references or names of Consider the grammar with the following
libraries with actual usable addresses in translation rules and E as the start symbol.
memory before running a program. Linker A -> A1 #B {A.value = A1.value * B.value}
performs it during compilation. | B {A.value = B.value}
B-> B1 & F {B.value = B1.value + C.value}
414. Which of the following statements is |C {B.value= C.value }
false? C -> num {C.value = num.value}.
a) Left as well as right most derivations can
be in Unambiguous grammar 416. Find the TRUE statement?
b) An LL (1) parser is a top-down parser
I. There exist parsing algorithms for some
c) LALR is more powerful than SLR
programming languages which has O(3)
d) Ambiguous grammar can‘t be LR (k)
complexity.
Answer: a
II. A programming language which allows
Explanation: If a grammar has more than
recursion can be implemented with static
one leftmost (or rightmost) derivation the
storage allocation.
grammar is ambiguous. Sometimes in
unambiguous grammar the rightmost III. No L-attributed definition can be
derivation and leftmost derivations may evaluated in The framework of bottom-up
differ. parsing.

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

IV. Code improving transformations can be Answer: a


performed at both intermediate code level Explanation: Recursive Descent also known
and source Language. as top down parsing also known to be LL(1).
Consider the following two statements:
a) I and II
P: Every regular grammar is LL(1)
b) I and IV
Q: Regular is LR(1) grammar.
c) III and IV
d) I III and IV 419. Which of the following is TRUE?
a) Both P and Q are true
Answer: b
b) P is true and Q is false
Explanation: In recursion, space used but
c) P is false and Q is true
recursive call can‘t be calculated by the
d) Both P and Q are false
compiler.
Answer: c
417. Which of the following describes a
Explanation: Ambiguity can be seen in
handle (as applicable to LR-parsing)
regular grammar
appropriately?
S → aA/a
a) Position where next reduce or shift
A → aA/ε
operation will occur
In above grammar, string ‗a‘ has two
b) The next step has use of Non-terminal for
leftmost
reduction
derivations.
c) Used for reduction in a coming-up step
S → aA
along with a position in the sentential form
S→a
where the next shift or reduce operation
S->a (using A->ε).
will occur
d) Used in the next step for reduction along 420. What is the grammar for the below
with a position in the sentential form where equations?
the right hand side of the production may
S→CC
be found
C→cC| d
Answer: d
Explanation: the next step in LR parsing a) LL(1)
shall have a Reduction. b) SLR(1) but not LL(1)
c) LALR(1) but not SLR(1)
418. Which one of the following is a top-
d) LR(1) but not LALR(1)
down parser?
a) Recursive descent parser Answer: a
b) Operator precedence parser Explanation: Since there is no conflict, the
c) An LR(k) parser grammar is LL (1) hence a predictive parse
d) An LALR(k) parser table with no conflicts can be constructed.

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)


lOMoARcPSD|5982446

421. Which of the following statements is 423. Which one of the following is true at
false? any valid state in shift-reduce parsing?
a) Unambiguous grammar has both kind of a) At the bottom we find the prefixes
derivations b) None of the mentioned
b) An LL(1) parser is a top-down parser c) Stack contains only viable prefixes
c) LALR is more powerful than SLR d) Stack consists of viable prefixes
d) Ambiguous grammar can‘t be LR(k)
Answer: c
Answer: a Explanation: The prefixes on the stack of a
Explanation: If a grammar has more than shift-reduce parser are called viable
one leftmost (or rightmost) derivation the prefixes.
grammar is ambiguous.

422. Given the following expression


grammar:

E -> E * F | F + E | F

F -> F - F | id

Which of the following is true?


a) * has higher precedence than +
b) – has higher precedence than *
c) + and — have same precedence
d) + has higher precedence than *

Answer: b
Explanation: e.g. input is 3*4-5 r

/ | \

E* F

| /|\

F F-F

| | |

id (3) id (4) id (5)

First ‗- ‗ is be evaluated then ‗ *‘

Downloaded by Prudhvi Dil (prudhvitejadil22@gmail.com)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy