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

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


MCQ Practice Test & Solutions: Test: Code Generation & Optimization- 2 (15 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- 2". These 15 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: 15

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

Test: Code Generation & Optimization- 2 - Question 1

In some phase of compiler 

Input
temp1 := Inttoreal (60)
temp2 := id3 * temp1 
temp3 := id2 + temp2
id1 := temp3
Output
temp 1 := id3 * 60.0
id1 := id2 + temp1

where temp 1 , temp 2 , temp 3 are temporary storage, id1, id2, Id3 are identifier into real is converting int 60 to real number. The above phase is

Detailed Solution: Question 1

Input:
temp1: = inttoreal(60)
temp2: = id3*temp1
temp3 : = id2 + temp2
id1 : = temp3

Output:
temp1 : = id3*60.0
id1 : id2 + temp1

The above phase is code optimization, because it is optimizing the intermediate code using only storages as temp 1 and id1.

Test: Code Generation & Optimization- 2 - Question 2

 The DAG shown here represents

Detailed Solution: Question 2

The above DAG represents
(a + b * C ) * { b * C - d )

Test: Code Generation & Optimization- 2 - Question 3

Any Directed Acyclic Graph must have

Detailed Solution: Question 3

Simplest DAG:

Test: Code Generation & Optimization- 2 - Question 4

The DAG shown here represents:

Detailed Solution: Question 4

Simplifying the DAG:

Thus result: (a + b) * (c + cf) + (a - b) * (c + d)

Test: Code Generation & Optimization- 2 - Question 5

 Consider the DAG with V = {1, 2, 3, 4, 5, 6}, shown below

Which of the following is NOT a topological ordering

Test: Code Generation & Optimization- 2 - Question 6

A directed acyclic graph represents one form of intermediate representation. The number of non terminals nodes in DAG of a = (b + c)*(b + c) expression is

Detailed Solution: Question 6

Since indegree of node 3 is 1. So cannot start topological ordering with node 3 only start node will be 1.

Test: Code Generation & Optimization- 2 - Question 7

A pictorial representation of the value computed by each statement in the basic block is

Detailed Solution: Question 7

A pictorial representation of the value computed by. each statement in the basic block is control flow graph.

Test: Code Generation & Optimization- 2 - Question 8

DAG representation of a basic block allows

Detailed Solution: Question 8

DAG representation of a basic block allows automatic detection of local common sub expression.

Test: Code Generation & Optimization- 2 - Question 9

The intermediate code generated for the following syntax tree is:

Detailed Solution: Question 9

The intermediate code generated is iacb + cd uminus * - +

Test: Code Generation & Optimization- 2 - Question 10

The triple representation for following representation is: 

Detailed Solution: Question 10

Reason (compact): treat * as indirection and avoid unary minus by rewriting
*y + (−*y) + z ≡ (z + *y) − *y.

Triples in (c) compute:

  • (0) + zt0 = z

  • (1) * yt1 = *y

  • (2) + z (1)t2 = t0 + t1

  • (3) * yt3 = *y

  • (4) - (2) (3)t4 = t2 − t3

  • (5) := x (4)x = t4

Thus it matches the expression.

Test: Code Generation & Optimization- 2 - Question 11

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

Detailed Solution: Question 11

Intermediate code enhance the portability of the front end of the compiler.

Test: Code Generation & Optimization- 2 - Question 12

Three address code’ technique for intermediate code generation shows that each statement usually contains three addresses. Three addresses are as follows:

Detailed Solution: Question 12

The technique of three address code for generating intermediate code typically involves three components:

  • Two addresses are used for operands, along with one address for the operator.
  • Alternatively, there is one address for the operator, one address for all operands, and one address for the result.
  • Finally, it can also be structured with one address for the result and two addresses for the operands.

Overall, the format allows for efficient computation and clarity in representing operations.

Test: Code Generation & Optimization- 2 - Question 13

Consider the following arithmetic infix expression Q.

A + (B * C - (D / E ^ F) * G) * H

Transform 'Q' into its equivalent postfix expression.

Detailed Solution: Question 13

  • Start by evaluating the innermost parenthesis: D / E ^ F.
  • Apply postfix for ^, /, then -: DE^F/.
  • Multiply with G: DE^F/G*.
  • Subtract from B * C: BC*DE^F/G*-.
  • Multiply by H: BC*DE^F/G*-H*.
  • Add A: ABC*DE^F/G*-H*+.
    Correct option: C.

Test: Code Generation & Optimization- 2 - Question 14

Which of the following is not a type of three address statements?

Test: Code Generation & Optimization- 2 - Question 15

Consider the following statements:
S1: Three address code is a linearized representation of a syntax tree.
S2: The syntax tree not depicts the natural hierarchical structure of source program

Which of the above statements is/are true

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