GateAI
Data Flow Analyses

GATE CSE 2026 Set 2 · Q45

MCQ2 marksMedium

Time

Consider the control flow graph given below. Which one of the following options is the set of live variables at the exit point of each basic block?

GATE CSE 2026 Set 2 Q45 diagram

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: A) B1:{a, b, c, e, f}, B2:{d, e}, B3:{b, c, e, f}, B4:Ø

Data Flow Analyses

To perform liveness analysis, we use the backward data-flow equations:

OUT[B]=⋃S∈succ(B)IN[S]\text{OUT}[B] = \bigcup_{S \in \text{succ}(B)} \text{IN}[S]
IN[B]=use[B]∪(OUT[B]∖def[B])\text{IN}[B] = \text{use}[B] \cup (\text{OUT}[B] \setminus \text{def}[B])

### Step 1: Identify use\text{use} and def\text{def} sets for each block

  • Block B1 (a=b+ca = b + c):

    use[B1]={b,c},def[B1]={a}\text{use}[B1] = \{b, c\}, \quad \text{def}[B1] = \{a\}
  • Block B2 (d=a+ed = a + e):

    use[B2]={a,e},def[B2]={d}\text{use}[B2] = \{a, e\}, \quad \text{def}[B2] = \{d\}
  • Block B3 (e=a+fe = a + f):

    use[B3]={a,f},def[B3]={e}\text{use}[B3] = \{a, f\}, \quad \text{def}[B3] = \{e\}
  • Block B4 (g=d+eg = d + e):

    use[B4]={d,e},def[B4]={g}\text{use}[B4] = \{d, e\}, \quad \text{def}[B4] = \{g\}

### Step 2: Compute IN\text{IN} and OUT\text{OUT} sets iteratively

  1. Block B4:

    • OUT[B4]=∅\text{OUT}[B4] = \emptyset

    • IN[B4]={d,e}∪(∅∖{g})={d,e}\text{IN}[B4] = \{d, e\} \cup (\emptyset \setminus \{g\}) = \{d, e\}

  2. Block B2:

    • OUT[B2]=IN[B4]={d,e}\text{OUT}[B2] = \text{IN}[B4] = \{d, e\}

    • IN[B2]={a,e}∪({d,e}∖{d})={a,e}\text{IN}[B2] = \{a, e\} \cup (\{d, e\} \setminus \{d\}) = \{a, e\}

  3. Iteration 1 for B3 and B1:

    • Initializing IN[B1]=∅\text{IN}[B1] = \emptyset:

      • OUT[B3]=IN[B1]=∅\text{OUT}[B3] = \text{IN}[B1] = \emptyset

      • IN[B3]={a,f}∪(∅∖{e})={a,f}\text{IN}[B3] = \{a, f\} \cup (\emptyset \setminus \{e\}) = \{a, f\}

    • For B1:

      • OUT[B1]=IN[B2]∪IN[B3]={a,e}∪{a,f}={a,e,f}\text{OUT}[B1] = \text{IN}[B2] \cup \text{IN}[B3] = \{a, e\} \cup \{a, f\} = \{a, e, f\}

      • IN[B1]={b,c}∪({a,e,f}∖{a})={b,c,e,f}\text{IN}[B1] = \{b, c\} \cup (\{a, e, f\} \setminus \{a\}) = \{b, c, e, f\}

  4. Iteration 2:

    • For B3:

      • OUT[B3]=IN[B1]={b,c,e,f}\text{OUT}[B3] = \text{IN}[B1] = \{b, c, e, f\}

      • IN[B3]={a,f}∪({b,c,e,f}∖{e})={a,b,c,f}\text{IN}[B3] = \{a, f\} \cup (\{b, c, e, f\} \setminus \{e\}) = \{a, b, c, f\}

    • For B1:

      • OUT[B1]=IN[B2]∪IN[B3]={a,e}∪{a,b,c,f}={a,b,c,e,f}\text{OUT}[B1] = \text{IN}[B2] \cup \text{IN}[B3] = \{a, e\} \cup \{a, b, c, f\} = \{a, b, c, e, f\}

      • IN[B1]={b,c}∪({a,b,c,e,f}∖{a})={b,c,e,f}\text{IN}[B1] = \{b, c\} \cup (\{a, b, c, e, f\} \setminus \{a\}) = \{b, c, e, f\}

  5. Iteration 3 (Convergence):

    • Values do not change, so the analysis has converged.

### Final OUT\text{OUT} sets (live variables at exit point):

  • B1: {a,b,c,e,f}\{a, b, c, e, f\}

  • B2: {d,e}\{d, e\}

  • B3: {b,c,e,f}\{b, c, e, f\}

  • B4: ∅\emptyset

Thus, (A) is the correct option [CS-2 Key].

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 Data Flow Analyses previous year question is Q45 of the GATE CSE 2026 Set 2 paper. Find more GATE CSE PYQs on Data Flow Analyses 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 Data Flow Analyses 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.

Data Flow Analyses in GATE CSE

Data Flow Analyses has 8 GATE CSE PYQs across 8 papers from 2014 to 2026. 5 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2026 Set 2.

How GATE tests Data Flow Analyses

More from GATE CSE 2026 Set 2

Share this solution

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

GateAI solution cardGATE CSE 2026 Set 2 · Q45 · MCQ

Consider the control flow graph given below. Which one of the following options is the set of live variables at the exit point of each basic block?

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.