GateAI
Intermediate Code Generation

GATE CSE 2015 Set 1 · Q55

NAT2 marksEasy

Time

The least number of temporary variables required to create a three-address code in static single assignment form for the expression q+r/3+s−t∗5+u∗v/wq + r / 3 + s - t * 5 + u * v / w is ______________.

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 8

Intermediate Code Generation

In Static Single Assignment (SSA) form, every variable must be assigned exactly once. Therefore, each intermediate operation generates a new, distinct temporary variable.

The given expression is:

q+r/3+s−t∗5+u∗v/wq + r / 3 + s - t * 5 + u * v / w

Following standard operator precedence (multiplication and division have higher precedence than addition and subtraction, with left-to-right associativity), the expression is evaluated as:

((((q+(r/3))+s)−(t∗5))+((u∗v)/w))((((q + (r / 3)) + s) - (t * 5)) + ((u * v) / w))

The three-address code in SSA form can be written as:

  1. t1=r/3t_1 = r / 3

  2. t2=q+t1t_2 = q + t_1

  3. t3=t2+st_3 = t_2 + s

  4. t4=t∗5t_4 = t * 5

  5. t5=t3−t4t_5 = t_3 - t_4

  6. t6=u∗vt_6 = u * v

  7. t7=t6/wt_7 = t_6 / w

  8. t8=t5+t7t_8 = t_5 + t_7

Since there are 88 binary operations and each definition must be assigned to a unique temporary variable in SSA form, a minimum of 8 temporary variables are required.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Intermediate Code Generation previous year question is Q55 of the GATE CSE 2015 Set 1 paper. Find more GATE CSE PYQs on Intermediate Code Generation in Compiler Design, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Intermediate Code Generation PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Intermediate Code Generation in GATE CSE

Intermediate Code Generation has 14 GATE CSE PYQs across 12 papers from 2011 to 2025. 3 of them are 2-mark NAT questions like this one, and it is the only one in GATE CSE 2015 Set 1.

How GATE tests Intermediate Code Generation

More from GATE CSE 2015 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2015 Set 1 · Q55 · NAT

The least number of temporary variables required to create a three-address code in static single assignment form for the expression q + r / 3 + s - t * 5 + u * v / w is …

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.