Time Left - 20:00 mins
GATE CS : Compiler Design Champion Quiz 5
Attempt now to get your rank among 362 students!
Question 1
Some code optimizations are carried out on the intermediate code because
Question 2
Which of the following statements is FALSE?
Question 3
One of the purposes of using intermediate code in compilers is to
Question 4
Which languages necessarily need heap allocation in the runtime environment?
Question 5
The syntax of the repeat-until statement is given by the following grammar
S →repeat S1 until E
Where E stands for expressions, S and S1 stand for statement. The non-terminals S and S1 have an attribute code that represents generated code. The nonterminal E has two attributes. The attribute code represents generated code to evaluate the expression and store its truth value in a distinct variable, and the attribute varName contains the name of the variable in which the truth value is stored? The truth-value stored in the variable is 1 if E is true, -2/3 if E is false. Give a syntax-directed definition to generate three-address code for the repeat-until statement. Assume that you can call a function new label( ) that returns a distinct label for a statement. Use the operator ‘\\’ to concatenate two strings and the function gen(s) to generate a line containing the string s.
S →repeat S1 until E
Where E stands for expressions, S and S1 stand for statement. The non-terminals S and S1 have an attribute code that represents generated code. The nonterminal E has two attributes. The attribute code represents generated code to evaluate the expression and store its truth value in a distinct variable, and the attribute varName contains the name of the variable in which the truth value is stored? The truth-value stored in the variable is 1 if E is true, -2/3 if E is false. Give a syntax-directed definition to generate three-address code for the repeat-until statement. Assume that you can call a function new label( ) that returns a distinct label for a statement. Use the operator ‘\\’ to concatenate two strings and the function gen(s) to generate a line containing the string s.
Question 6
Which of the following is NOT an advantage of using shared, dynamically linked libraries as opposed to using statically linked libraries?
Question 7
Consider the following class definitions in a hypothetical Object Oriented language that supports inheritance and uses dynamic binding. The language should not be assumed to be either Java or C++, though the syntax is similar.
Class P { Class Q subclass of P {
void f(int i) { void f(int i) {
print(i); print(2*i);
} }
} }
Now consider the following program fragment:
Px = new Q()
Qy = new Q();
Pz = new Q();
x.f(1); ((P)y).f(1); z.f(1);
Here ((P)y) denotes a typecast of y to P. The output produced by executing the above program fragment will be
Class P { Class Q subclass of P {
void f(int i) { void f(int i) {
print(i); print(2*i);
} }
} }
Now consider the following program fragment:
Px = new Q()
Qy = new Q();
Pz = new Q();
x.f(1); ((P)y).f(1); z.f(1);
Here ((P)y) denotes a typecast of y to P. The output produced by executing the above program fragment will be
Question 8
Consider the basic block given below.
a = b + c
c = a + d
d = b + c
e = d – b
a = e + b
The minimum number of nodes and edges present in the DAG representation of the above basic block respectively are
a = b + c
c = a + d
d = b + c
e = d – b
a = e + b
The minimum number of nodes and edges present in the DAG representation of the above basic block respectively are
Question 9
Consider the following C code segment.
for (i – 0, i<n; i++) {
for (j=0; j<n; j++) {
if (i%2) {
x += (4*j + 5*i);
y += (7 + 4*j);
}
}
}
Which one of the following is false?
for (i – 0, i<n; i++) {
for (j=0; j<n; j++) {
if (i%2) {
x += (4*j + 5*i);
y += (7 + 4*j);
}
}
}
Which one of the following is false?
Question 10
Identify an equivalent non-left recursive CFG for the following CFG.
EE+T|E*T|T
TT-F|F
FF+2|id
- 362 attempts
- 1 upvote
- 9 comments
Jun 25GATE & PSU CS