Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Test  >  GATE Computer Science Engineering(CSE) 2027 Mock Test Series  >  Test: Code Generation & Optimization- 1 - Computer Science Engineering (CSE) MCQ

GATE Computer Science Engineering(CSE) 2027 Test: Code Generation & Optimization-


MCQ Practice Test & Solutions: Test: Code Generation & Optimization- 1 (10 Questions)

You can prepare effectively for Computer Science Engineering (CSE) GATE Computer Science Engineering(CSE) 2027 Mock Test Series with this dedicated MCQ Practice Test (available with solutions) on the important topic of "Test: Code Generation & Optimization- 1". These 10 questions have been designed by the experts with the latest curriculum of Computer Science Engineering (CSE) 2026, to help you master the concept.

Test Highlights:

  • - Format: Multiple Choice Questions (MCQ)
  • - Duration: 30 minutes
  • - Number of Questions: 10

Sign up on EduRev for free to attempt this test and track your preparation progress.

Test: Code Generation & Optimization- 1 - Question 1

A non relocatable program is one which

Detailed Solution: Question 1

The phases of compiler
1. Lexical
2. Syntax
3. Semantic
4. Intermediate code generation, are all machine dependent phases and are not relocatable.
The together make pass-1 of the compiler. This program hence can not be made to execute in any area of storage other than the one designated for it at the time of its coding or translation.

Test: Code Generation & Optimization- 1 - Question 2

A self relocating program is one which

Detailed Solution: Question 2

The self relocating program is one which can itself perform the relocation of its address sensitive portion. Code-optimization and target code generation comes under the pass-2 of the compiler and is machine independent.

Test: Code Generation & Optimization- 1 - Question 3

Generation of intermediate code based on an abstract machine model is useful in compilers because

Detailed Solution: Question 3

Option C is correct.

Abstract machine model provides a machine-independent representation so the front end can generate a single intermediate code that is not tied to any real machine.

This improves portability because the same front end can be paired with different back ends (target code generators) for different machines without changing the front end.

Although syntax-directed translations can be used to produce intermediate code, that statement (Option B) is a general fact about implementation technique and does not specifically capture the benefit of using an abstract machine model for portability, which is the key point here.

Option A is incorrect because lexical and syntax analysis are performed before intermediate code generation; choosing an abstract machine model does not make these analyses easier.

Option D is incorrect because it is possible to generate code directly for real machines; using an intermediate representation is a design choice to improve modularity and portability, not because direct generation is impossible.

Therefore, Option C best answers the question.

Test: Code Generation & Optimization- 1 - Question 4

Consider the adjacent binary tree:

$ denotes exponentiation. If the tree is traversed in preorder, which, if any, of the expressions below is formed?

Detailed Solution: Question 4


The preorder expansion can be represented as 

$ + x*yz* + xyz

Test: Code Generation & Optimization- 1 - Question 5

Which of the following cannot be used as an intermediate code form?

Detailed Solution: Question 5

Quadruples is not the intermediate code form.

Test: Code Generation & Optimization- 1 - Question 6

A basic block can be analyzed by

Detailed Solution: Question 6

Properties of a basic block are as follows:

  • The flow of control can only enter the basic block through the first instruction in the block.
  • No numps in the middle of the block.
  • Control leaves the block without halting/branching.

The basic blocks become the nodes of a flow graph, whose edges indicate which blocks can follows which other blocks.

Test: Code Generation & Optimization- 1 - Question 7

The graph that shows the basic blocks and their successor relationship is called

Detailed Solution: Question 7

The graph that shows the basic blocks and their successor relationship is called control graph.

Test: Code Generation & Optimization- 1 - Question 8

Consider the following C code segment: 

Which one of the following is false?

Detailed Solution: Question 8

(a) i%2 is inner loop invariant, it can be moved before inner loop.
(b) 4*j is common sub-expression-appeared in two statements.
(c) 4*j can be reduced to j<<2 by strength reduction.
(d) There is no dead code in given code segment. So there is no scope of dead code elimination in this code.
Hence only option (d) is FALSE.

Test: Code Generation & Optimization- 1 - Question 9

Some code optimizations are carried out on the intermediate code because

Detailed Solution: Question 9

Some code optimizations are carried out on the intermediate code because program analysis is more accurate on intermediate code than on machine code.

Test: Code Generation & Optimization- 1 - Question 10

Which languages necessarily need heap allocation in the runtime environment?

Detailed Solution: Question 10

Runtime environment means we deal with dynamic memory allocation and Heap is a dynamic data structure.
So it is clear that those languages that allow dynamic data structure necessarily need heap allocation in the runtime environment.

56 docs|215 tests
Information about Test: Code Generation & Optimization- 1 Page
In this test you can find the Exam questions for Test: Code Generation & Optimization- 1 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Code Generation & Optimization- 1, EduRev gives you an ample number of Online tests for practice
Download as PDF