Home / Engineering / Theory of Computation and Compiler Design MCQs / Page 8

Theory of Computation and Compiler Design MCQs | Page - 8

Dear candidates you will find MCQ questions of Theory of Computation and Compiler Design here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.

M

Mr. Dubey • 51.17K Points
Coach

Q. 71) Which of the following grammar rules violate the requirements of an operator grammar ? P, Q, R are nonterminals, and r, s, t are terminals.
1. P → Q R
2. P → Q s R
3. P → ε
4. P → Q t R r

(A) 1 only
(B) 1 and 3 only
(C) 2 and 3 only
(D) 3 and 4 only
View Answer Discuss Share

M

Mr. Dubey • 51.17K Points
Coach

Q. 72) Consider the grammar with the following translation rules and E as the start symbol.
E → E1 # T { E.value = E1.value * T.value } | T{ E.value = T.value }
T → T1 & F { T.value = T1.value + F.value } | F{ T.value = F.value }
F → num { F.value = num.value }
Compute E.value for the root of the parse tree for the expression: 2 # 3 & 5 # 6 & 4.

(A) 200
(B) 180
(C) 160
(D) 40
View Answer Discuss Share

M

Mr. Dubey • 51.17K Points
Coach

Q. 73) Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states. The relationship between n1 and n2 is:

(A) n1 is necessarily less than n2
(B) n1 is necessarily equal to n2
(C) n1 is necessarily greater than n2
(D) none of these
View Answer Discuss Share

M

Mr. Dubey • 51.17K Points
Coach

Q. 74) Consider the grammar shown below S → i E t S S' | a S' → e S | ε E → b In the predictive parse table. M, of this grammar, the entries M[S', e] and M[S', $] respectively are

(A) {S' → e S} and {S' → e}
(B) {S' → e S} and {}
(C) {S' → ε} and {S' → ε}
(D) {S' → e S, S'→ ε} and {S' → ε}
View Answer Discuss Share

M

Mr. Dubey • 51.17K Points
Coach

Q. 75) Consider the translation scheme shown below
S → T R
R → + T {print ('+');} R | ε
T → num {print (num.val);}
Here num is a token that represents an integer and num.val represents the
corresponding integer value. For an input string '9 + 5 + 2', this translation scheme will
print

(A) 9 + 5 + 2
(B) 9 5 + 2 +
(C) 9 5 2 + +
(D) + + 9 5 2
View Answer Discuss Share

M

Mr. Dubey • 51.17K Points
Coach

Q. 76) Which of the following is essential for converting an infix expression to the postfix from efficiently?

(A) An operator stack
(B) An operand stack
(C) An operand stack and an operator stack
(D) A parse tree
View Answer Discuss Share

M

Mr. Dubey • 51.17K Points
Coach

Q. 77) The grammar whose productions are
<stmt> → if id then <stmt>
<stmt> → if id then <stmt> else <stmt>
<stmt> → id := id
is ambiguous because
a) the sentence if a then if b then c:= d has two parse trees
b) the left most and right most derivations of the sentence if a then if b then c:= d give rise to different parse trees
c) the sentence if a then if b then c:= d else c:= f has more than two parse trees
d) the sentence if a then if b then c:= d else c:= f has two parse trees

(A) a
(B) b
(C) c
(D) d
View Answer Discuss Share

M

Mr. Dubey • 51.17K Points
Coach

Q. 78) Consider the following grammars
(S1) :
A --> aBCD
B --> bc|c
C --> d|∈
D -> b
(S2) :
A --> aBCD
B --> bc|∈
C --> d|c
D -> b
(S3) :
A --> aBCD
B --> bc|∈
C --> d|∈
D -> b
(S4) :
A --> aBCD
B --> bc|c
C --> d|c
D -> b
Which of the following grammar has same follow set for variable B?

(A) Only (S1), (S2) and (S3), (S4)
(B) Only (S1), (S3) and (S2), (S4)
(C) Only (S2), (S3) and (S1), (S4)
(D) None of the above
View Answer Discuss Share

M

Mr. Dubey • 51.17K Points
Coach

Q. 79) Which is True about SR and RR-conflict:

(A) If there is no SR-conflict in CLR(1) then definitely there will be no SR-conflict in LALR(1).
(B) RR-conflict might occur if lookahead for final items(reduce-moves) is same.
(C) Known that CLR(1) has no RR-conflict, still RR-conflict might occur in LALR(1).
(D) All of the above.
View Answer Discuss Share

M

Mr. Dubey • 51.17K Points
Coach

Q. 80) Which of the following statement(s) regarding a linker software is/are true ? I A function of a linker is to combine several object modules into a single load module. II A function of a linker is to replace absolute references in an object module by symbolic references to locations in other modules.

(A) Only I
(B) Only II
(C) Both I and II
(D) Neither I nor II
View Answer Discuss Share