GateAI
Local Optimisation

GATE CSE 2014 Set 3 · Q34

MCQ2 marksMedium

Time

Consider the basic block given below.a = b + c c = a + d d = b + c e = d - b a = e + bThe minimum number of nodes and edges present in the DAG representation of the above basic block respectively are

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: A) 6 and 6

Local Optimisation

Let us construct the Directed Acyclic Graph (DAG) for the basic block:

  1. a = b + c

    • Leaf nodes: b0b_0, c0c_0

    • Node n1=(+,b0,c0)n_1 = (+, b_0, c_0), labeled {a1}\{a_1\} (2 edges)

  2. c = a + d

    • Leaf node: d0d_0

    • Node n2=(+,n1,d0)n_2 = (+, n_1, d_0), labeled {c1}\{c_1\} (2 edges)

  3. d = b + c

    • Node n3=(+,b0,n2)n_3 = (+, b_0, n_2), labeled {d1}\{d_1\} (2 edges)

  4. e = d - b

    • Since d=b+c1d = b + c_1, the expression e=d−b=(b+c1)−b=c1e = d - b = (b + c_1) - b = c_1.

    • Thus, ee evaluates to the value represented by node n2n_2, so label ee is attached to n2n_2.

  5. a = e + b

    • Since ee is n2n_2, e+b=n2+b0=b0+n2e + b = n_2 + b_0 = b_0 + n_2, which is already computed at node n3n_3.

    • Thus, the new value of aa is attached to node n3n_3.

Total Nodes:

  • 3 leaf nodes: b0,c0,d0b_0, c_0, d_0

  • 3 interior operation nodes: n1(+),n2(+),n3(+)n_1 (+), n_2 (+), n_3 (+)

  • Total nodes = 3+3=63 + 3 = 6

Total Edges:

  • n1→b0,c0n_1 \to b_0, c_0 (2 edges)

  • n2→n1,d0n_2 \to n_1, d_0 (2 edges)

  • n3→b0,n2n_3 \to b_0, n_2 (2 edges)

  • Total edges = 2+2+2=62 + 2 + 2 = 6

Therefore, the minimum number of nodes and edges is 6 and 6, which corresponds to option (A).

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 Local Optimisation previous year question is Q34 of the GATE CSE 2014 Set 3 paper. Find more GATE CSE PYQs on Local Optimisation 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 4 related Local Optimisation 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.

Local Optimisation in GATE CSE

Local Optimisation has 4 GATE CSE PYQs across 4 papers from 2013 to 2025. 3 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2014 Set 3.

How GATE tests Local Optimisation

More from GATE CSE 2014 Set 3

Share this solution

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

GateAI solution cardGATE CSE 2014 Set 3 · Q34 · MCQ

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

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.