Unit 8pdf
Unit 8pdf
Unit - 8
Or
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
Answer: b
Explanation: Bounded information refers to
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
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.
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
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.
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
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.
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}
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
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
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}
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.
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.
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.
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)
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
and right parentheses, and so they cannot c) both (a) and (b)
be balanced. d) none of the mentioned
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?
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
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.
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?
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.
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.
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.
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,
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
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
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
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
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
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
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
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
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
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
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
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
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
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?
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
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)
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.
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?
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
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
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
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.
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
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.
E -> E * F | F + E | F
F -> F - F | id
Answer: b
Explanation: e.g. input is 3*4-5 r
/ | \
E* F
| /|\
F F-F
| | |