CD CT 3 2022 Paper
CD CT 3 2022 Paper
H H H
CO1 H H M L M M L H
CO2 H M M H H
H H M L L
3 CO3 H H H H L M M H H H
M L
M H H H H
CO4 H H M L L M L
COS H H H H M L L L M L H H
6 H H H
CO6 H H H H M L M M
Part- A
Answer all (20 x 1=20 marks)
Q. Question Mar BL CO PO PI
No ks Code
1 The sequence of procedure calls of a program corresponds 1 4 1.6.1
to which traversal of the activation tree?
A. In order traversal B. Pre order traversal
C. Post order traversal D. Level order traversal
Consider the code following to apply the dead code 1 4 2 2.6.2
elimination,
If (Condition)
{ a=y OP z;
else
c=y OP z;
yOP z should be computed as how many times in optimized
code?
A. one B. Two C. Three D. Four
Which algorithm invokes a function GETREGO? 2 4 2.6.2
A Code motion algorithm B. Code optimization
algorithm
C Intermediate Code D. Code generation
algorithm
Consider the internediate code given below. 2 4 2 2.7.1
(1)i=1
(2)j = 1
(3) tl = 5 *i
(4) t2 = tl+j
(5) t3 =4 * t2
(6) t4 = t3
(7) a[t4] =-1
(8)j=j+1
(9) ifj< = 5 goto (3)
(10)i= i+1
(11) ifi<S goto (2)
The number of nodes and edges in the control-flow-graph
constructed for the above code, respectively, are
a) 5 and 7 b) 5 and 5 c) 6 and7 d) 7 and 8
2 4 1.6.1
5 Which of the following is not a three-address code?
a). a =5 b) b=a c) C=a+b d) d=a+b-c
1 2 1.7.1
The postfix representation of the following expression:
(x+y) *(x-y)
a) +x y* - xy b)x y+ * xy -
C)x y+xy - * d)x y+xy* - 1 1.5.]
7 How many leaders are there in the following code?
Goto LA
L1: a-atb
Goto L1
Goto L2
L2: a=a-b
Goto Ll
Goto L2
LA: c=atb+8
a) 8 b) 5 c) 4 d) 3
Which optimization techniques is used to reduce multiple jumps? 1 2 2.7.1
A. Latter optimization technique
B. Peephole optimization technique
C. Local optimization technique
D. Code optimization technique
Generation of Intermediate code based on a abstract 5 2 2.8.:
machine model is useful in Compilers because,
A. Makes implementation of LA & Syntax Analysis easier
B. SDT can be written for ICG
C. Enhances the portability of the front end of thc Compiler
D. Not possible to generate code for real machines directly from
high level language programs
10 Consider the following code. The following variables at line 1 1 1.6.1
number (3) does not have next use
(1) x= ytz
(2) z= x* 6
(3) t= z+]
(4) y--t
(5) x=z+y
a) all the variablcs havc ncxt use b) t c)z d) y
The following code is an cxamplc of? 2 6 1.7.1
voidaddten(int x)
return x 10;
printf(""valuc of x is %d"", x);
(A) Redundant instruction elimination B. Unrcachablc code
(C) Flow of control optimization D. Reachable code
12 Consider the following three address code. ldentify the 6 1.6.1
CORRECT collection of different optimization can be
perfoned?
m =3
j=n
V=2*n
limit = integer n / 2
L1: j=j-1
t4 = 4 *j
t5 = a[t4]
if t5 > limitv goto LI
A. Code Motion, Constant Folding, Induction Variable
Elimination, Reduction in Strcngth
B. Copy Propagation , Code Moion, Deadcode Elimination,
Reduction in Strength
C. Constant Folding, Copy Propagation, Deadcode
Elimination, Reduction in Strength
D. Code Motion, Constant Folding, Copy Propagation,
Induction Variable Elimination
13 In algebraic expression simplification, a=atl can simply be 2 2 2.7.2
replaced by?
A. a B. INC a C. DECa D. MUL a
14 SDT scheme is desirable because, 2 6 1
A. It is based on the syntax 1.6.1
B. Its description is independent of any
C. It is easy to modify implementation
D. It is unable to modify
15 Which graph describes the basic block and
successor 6 2.6.2
relationship?
a) Control Graph b) DAG c) Flow graph d)
Hamiltonian graph
16 | Identifying the class of statement when
produce any executable code compiled does not 6 2 2.6.3
A. Structural statement
B. VO statement
C. Assignment statement D. Declaration
17 The definitions that are alive in B2 of the
are:
given flow graph 6 3 3.5.2
a) d2 and dl
b) dl and d3
b) dl,d2, d3 d) all are alive
18 technique used to
with both synthesized andevaluate syntax directed definiions 6 4
A. Eval Graphs
inherited attributes. 4.4.2
C. SDD Graphs
B. SD graphs
is a Synax D. Dependency graph
19 Directed Definition that uses only
synthesized uttributes. 1.6.1
A. A-Syntax Definition B. K. Dirccted
Definition
C. N-SD Definition D. S-Attributed
definition 1.6.]
1
20 Cros-compiler is a compiler
A. Which is written in a different language from the source
language?
B. That generates object code for the machine it's running on.
C. Which is written in the same language as the source language?
D. That runs on one machine but produces objcct code for another
machine
Part - B
Answer any three (3 x 10=30 marks)
Marks BL CO PO PI
Q. Question Cod
No 6 4 6 6.3.)
Generate the three-address code statement and construct 10
21
the DAG representation for the cxpression
at a*(b-c) +(b-c) *d.
10 4 4.13
22 Apply the peephole optimization for the given code.
i = 1
i£ > a goto 15
ti = addr (a) - 4
t2 i 4
t3 t l (t21
t4 addr (a) - 4
8. tS i * 4
9. t6 t4 (t5]
10 t7 t3 * t6
11. t8 8un+ t7
12. t8
13. i i + 1
14. goto 3
3 6 2.1.:
23 Consider the following code, find out the minimum 10
number of registers required to compile he given code
a) with optimizations and b) without optimization
/=a a;
clae 4
d = d a;
6 1,3.1
24 Disçuss in detail about storage allocation strategics.