Skip to content

UGC NET CS 2019Theory of Computation and Compilers › Code Generation and Code OptimizationVerified

UGC NET CS 2019 PYQ: A flow graph $F$ with entry node $(1)$ and exit node $(11)$ is shown below: How many nodes are there in the…

A flow graph $F$ with entry node $(1)$ and exit node $(11)$ is shown below:

UGC NET CS 2019 Code Generation and Code Optimization diagram: A flow graph $F$ with entry node $(1)$ and exit node $(11)$

How many nodes are there in the longest independent path?

  1. A
    6
  2. B
    7
    Correct answer
  3. C
    8
  4. D
    9

Answer

(B) 7

Approach

The flow graph has edges: $1\to(2,3)$, $(2,3)\to 6$, $(2,3)\to(4,5)$, $6\to 7$, $6\to 8$, $7\to 9$, $8\to 9$, $9\to 10$, $(4,5)\to 10$, $10\to 11$, plus the back edge $10\to 1$ and $1\to 11$. The longest independent (simple, acyclic) path avoids the feedback edge $10\to 1$ and takes the branch with the most nodes. Going through node 6 and 7: $1\to(2,3)\to 6\to 7\to 9\to 10\to 11$, giving nodes $1,(2,3),6,7,9,10,11 = 7$ nodes. The parallel branch via 8 yields the same count ($1,(2,3),6,8,9,10,11$), and the branch through $(4,5)$ is shorter. Hence the longest independent path contains 7 nodes, matching option B.

Reviewed by UGC IQ Editorial Team.