StreakPeaked· Practice

ExamsGATETechnical

Consider the following basic block: $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

  1. 6 and 6
  2. 8 and 10
  3. 9 and 12
  4. 4 and 4

Correct answer: 6 and 6

Solution

In a DAG for a basic block, identical expressions are represented once and variable names are attached to nodes. Here, the computations can be organized with minimal sharing so that the representation uses 6 nodes and 6 edges. This is the standard DAG optimization idea used in compiler design.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →