Compiler Design questions

Q19

GATE CS 2016 CS-1Intermediate CodeNAT1 mark
Consider the following code segment.
x = u - t;
y = x * v;
x = y + w;
y = t - z;
y = x * y;
The minimum number of total variables required to convert the above code segment to static single assignment form is ________.
Show answer without attempting

Answer: 10.0

Q36

GATE CS 2016 CS-1Runtime EnvironmentsMCQ2 marks−2/3 if wrong
What will be the output of the following pseudo-code when parameters are passed by reference and dynamic scoping is assumed?
a=3;
void n(x) {x = x * a; print(x);}
void m(y) {a = 1; a = y - a; n(a); print(a);}
void main() {m(a);}
Show answer without attempting

Answer: D

Q46

GATE CS 2016 CS-1Syntax Directed TranslationMCQ2 marks−2/3 if wrong
Consider the following Syntax Directed Translation Scheme (SDTS), with non-terminals {S, A} and terminals {a, b}.
S→aA{print 1}S \to aA \{ \text{print } 1 \}
S→a{print 2}S \to a \{ \text{print } 2 \}
A→Sb{print 3}A \to Sb \{ \text{print } 3 \}
Using the above SDTS, the output printed by a bottom-up parser, for the input aab is:
Show answer without attempting

Answer: C

Q19

GATE CS 2016 CS-2Lexical AnalysisMCQ1 mark−1/3 if wrong
Match the following:

(P) Lexical analysis --- (i) Leftmost derivation
(Q) Top down parsing --- (ii) Type checking
(R) Semantic analysis --- (iii) Regular expressions
(S) Runtime environments --- (iv) Activation records
Show answer without attempting

Answer: B

Q45

GATE CS 2016 CS-2ParsingMCQ2 marks−2/3 if wrong
Which one of the following grammars is free from left recursion?
Show answer without attempting

Answer: B

0/50 correct0 marks

Related topics in GATE CS