My Cart
Your Cart 0

    Your cart is empty.

  • Total (Amount) ₹0.00
Previous year question hub

Code Generation and Optimization - Compiler Design - Computer Science & Information Technology Previous Year Questions

Practice Code Generation and Optimization - Compiler Design - Computer Science & Information Technology previous year questions organised from real papers, with year-wise coverage and clear topic navigation.

18Papers
12Years
25Questions
1Topics

Code Generation and Optimization question pattern

Every graph below is calculated only from this selection.

Questions by year

Compare question counts across years.

Difficulty distribution

How the classified questions are distributed by difficulty.

Medium 14 56%
Easy 9 36%
Hard 2 8%

Question type distribution

MCQ, numerical, multiple-select and other formats found in these papers.

MCQ 20 80%
MSQ 3 12%
Numerical Answer Type (NAT) 1 4%
Fill in the blanks 1 4%

Subject weightage

Top subjects by unique question coverage.

Computer Science & Information Technology
25 Qs

Most asked topics

Top topics across the included previous year papers.

Compiler Design
25 Qs

Subtopic coverage

Top subtopics inside this exact selection.

Code Generation and Optimization
25 Qs

Paper coverage

Question coverage for the most populated papers. Every active PYP paper remains listed below.

Computer Science and Information Technology (CS) 2026
1 Qs
Computer Science and Information Technology (CS) 2026
1 Qs
Computer Science & Information Technology (CS) 2025 [Session 1]
2 Qs
Computer Science & Information Technology (CS) 2025 [Session 2]
1 Qs
Computer Science & Information Technology (CS) 2024 [Session 1]
1 Qs
Computer Science & Information Technology (CS) 2024 [Session 2]
1 Qs
Computer Science & Information Technology (CS) 2021 [Session 2]
2 Qs
Computer Science & Information Technology (CS) 2017 [Session 1]
1 Qs
Computer Science & Information Technology (CS) 2015 [Session 2]
1 Qs
Computer Science & Information Technology (CS) 2014 [Session 3]
2 Qs
Computer Science & Information Technology (CS) 2014 [Session 1]
1 Qs
Computer Science & Information Technology (CS) 2013 [Session 1]
2 Qs
Computer Science & Information Technology (CS) 2013 [Session 3]
2 Qs
Computer Science & Information Technology (CS) 2013 [Session 4]
2 Qs
Computer Science & Information Technology (CS) 2011
1 Qs
Computer Science & Information Technology (CS) 2010
2 Qs
Computer Science & Information Technology (CS) 2008
1 Qs
Computer Science & Information Technology (CS) 2007
1 Qs

Included previous year papers

Newest papers appear first. Search these papers or sort by year and name.

Paper nameYearPDFAttempt
Computer Science and Information Technology (CS) 20262026
1 questions in this view
2026
Computer Science and Information Technology (CS) 20262026
1 questions in this view
2026
Computer Science & Information Technology (CS) 2025 [Session 1]2025
2 questions in this view
2025
Computer Science & Information Technology (CS) 2025 [Session 2]2025
1 questions in this view
2025
Computer Science & Information Technology (CS) 2024 [Session 1]2024
1 questions in this view
2024
Computer Science & Information Technology (CS) 2024 [Session 2]2024
1 questions in this view
2024
Computer Science & Information Technology (CS) 2021 [Session 2]2021
2 questions in this view
2021
Computer Science & Information Technology (CS) 2017 [Session 1]2017
1 questions in this view
2017
Computer Science & Information Technology (CS) 2015 [Session 2]2015
1 questions in this view
2015
Computer Science & Information Technology (CS) 2014 [Session 1]2014
1 questions in this view
2014
Computer Science & Information Technology (CS) 2014 [Session 3]2014
2 questions in this view
2014
Computer Science & Information Technology (CS) 2013 [Session 1]2013
2 questions in this view
2013
Computer Science & Information Technology (CS) 2013 [Session 3]2013
2 questions in this view
2013
Computer Science & Information Technology (CS) 2013 [Session 4]2013
2 questions in this view
2013
Computer Science & Information Technology (CS) 20112011
1 questions in this view
2011
Computer Science & Information Technology (CS) 20102010
2 questions in this view
2010
Computer Science & Information Technology (CS) 20082008
1 questions in this view
2008
Computer Science & Information Technology (CS) 20072007
1 questions in this view
2007

All Code Generation and Optimization previous year questions

Practice every matching question in batches of 20, with every available option.

1
2007 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2007
In a simplified computer the instructions are:
OP Ri,Rj - Performs Ri OP Rj and stores the result in register Ri.
OP m,Ri - Performs val OP Ri and stores the result in Ri. val denotes the content of memory location m.
MOV m,Ri - Moves the content of memory location m to register Ri.
MOV Ri,m - Moves the content of register Ri to memory location m.
The computer has only two registers, and OP is either ADD or SUB. Consider the following basic block:
t1 = a + b
t2 = c + d
t3 = e – t2
t4 = t1 – t3
Assume that all operands are initially in memory. The final value of the computation should be in memory. What is the minimum number of MOV instructions in the code generated for this basic block?
Open complete paper
2
2008 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2008
Some code optimizations are carried out on the intermediate code because
Open complete paper
3
2010 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2010

The cyclomatic complexity of each of the modules A and B shown below is 10. What is the cyclomatic complexity of the sequential integration shown on the right hand side?

Question diagram

Open complete paper
4
2010 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2010
The program below uses six temporary variables a, b, c, d, e, f.
a = 1
b = 10
c = 20
d = a + b
e = c + d
f = c + e
b = c + e
e = b + f
d = 5 + e
return d + f
Assuming that all operations take their operands from registers, what is the minimum number of registers needed to execute this program without spilling?
Open complete paper
5
2013 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2013 [Session 1]
Suppose the instruction set architecture of the processor has only two registers. The only allowed compiler optimization is code motion, which moves statements from one place to another while preserving correctness. What is the minimum number of spills to memory in the compiled code?
Open complete paper
6
2013 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2013 [Session 1]
What is the minimum number of registers needed in the instruction set architecture of the processor to compile this code segment without any spill to memory? Do not apply any optimization other than optimizing register allocation.
Open complete paper
7
2014 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2014 [Session 1]
Which one of the following is FALSE?
Open complete paper
8
2014 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2014 [Session 3]
One of the purposes of using intermediate code in compilers is to
Open complete paper
9
2014 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2014 [Session 3]
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
Open complete paper
10
2015 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2015 [Session 2]
Consider the intermediate code given below.
(1)  i = 1
(2)  j = 1
(3)  t1 = 5 * i
(4)  t2 = t1 + j
(5)  t3 = 4 * t2
(6)  t4 = t3
(7)  a[t4] = -1
(8)  j = j + 1
(9)  if j <= 5 goto (3)
(10)  i=i+1
(11)  if i < 5 goto (2)
The number of nodes and edges in the control-flow-graph constructed for the above code, respectively, are
Open complete paper
11
2021 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2021 [Session 2]
Consider the following ANSI C code segment:
z = x + 3 + y->f1 + y->f2;
for (i = 0; i < 200; i = i + 2) {
if (z > i) {
p = p + x + 3;
q = q + y->f1;
} else {
p = p + y->f2;
q = q + x + 3;
}
}
Assume that the variable y points to a struct (allocated on the heap) containing two fields f1 and f2, and the local variables x, y, z, p, q, and i are allotted registers. Common sub-expression elimination (CSE) optimization is applied on the code. The number of addition and dereference operations (of the form y->f1 or y->f2) in the optimized code, respectively, are:
Open complete paper
12
2021 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2021 [Session 2]

For a statement \(S\) in a program, in the context of liveness analysis, the following sets are defined:

\(USE(S)\) : the set of variables used in \(S\)

\(IN(S)\) : the set of variables that are live at the entry of \(S\)

\(OUT(S)\) : the set of variables that are live at the exit of \(S\)

Consider a basic block that consists of two statements, \(S_1\) followed by \(S_2\). Which one of the following statements is correct?

Open complete paper
13
2024 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2024 [Session 1]
Consider the following pseudo-code.
L1: t1 = -1
L2: t2 = 0
L3: t3 = 0
L4: t4 = 4 * t3
L5: t5 = 4 * t2
L6: t6 = t5 * M
L7: t7 = t4 + t6
L8: t8 = a[t7]
L9: if t8 <= max goto L11
L10: t1 = t8
L11: t3 = t3 + 1
L12: if t3 < M goto L4
L13: t2 = t2 + 1
L14: if t2 < N goto L3
L15: max = t1
Which one of the following options CORRECTLY specifies the number of basic blocks and the number of instructions in the largest basic block, respectively ?
Open complete paper
14
2024 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2024 [Session 2]
Consider the following expression: x[i] = (p + r) * -s[i] + u/w. The following sequence shows the list of triples representing the given expression, with entries missing for triples (1), (3), and (6).
(0)+pr
(1)
(2)uminus(1)
(3)
(4)/uw
(5)+(3)(4)
(6)
(7)=(6)(5)

Which one of the following options fills in the missing entries CORRECTLY?
Open complete paper
15
2025 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2025 [Session 1]

Which ONE of the following techniques used in compiler code optimization uses live variable analysis?

Open complete paper
16
2025 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2025 [Session 1]
Refer to the given 3-address code sequence. This code sequence is split into basic blocks. The number of basic blocks is ______. (Answer in integer)

Question diagram

Open complete paper
17
2025 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2025 [Session 2]
Consider the following statements about the use of backpatching in a compiler for intermediate code generation:
(I) Backpatching can be used to generate code for Boolean expression in one pass.
(II) Backpatching can be used to generate code for flow-of-control statements in one pass.
Which ONE of the following options is CORRECT?
Open complete paper
18
2011 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2011
Consider evaluating the following expression tree on a machine with load-store architecture in which memory can be accessed only through load and store instructions. The variables \(a, b, c, d\) and \(e\) are initially stored in memory. The binary operators used in this expression tree can be evaluated by the machine only when the operands are in registers. The instructions produce result only in a register. If no intermediate results can be stored in memory, what is the minimum number of registers needed to evaluate this expression?
Open complete paper
19
2017 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science & Information Technology (CS) 2017 [Session 1]
Consider the expression \((a-1)*(((b+c)/3)+d)\)). Let X be the minimum number of registers required by an optimal code generation (without any register spill) algorithm for a load/store architecture, in which (i) only load and store instructions can have memory operands and (ii) arithmetic instructions can have only register or immediate operands. The value of X is __________.
Open complete paper
20
2026 · Computer Science & Information Technology · Compiler Design · Code Generation and Optimization
Computer Science and Information Technology (CS) 2026
Consider the control flow graph shown in the figure.
Which one of the following options correctly lists the set of redundant expressions (common subexpressions) in the basic blocks B4 and B5?
Note: All the variables are integers.

Question diagram

Open complete paper

Showing 20 of 21 questions