CS FundamentalsVery hardGATE CS · product placement

A control-flow graph has nodes 1-8 and edges 1→2; 2→3, 2→4, 2→5 (a switch); 3→6; 4→6; 5→6; 6→7, 6→8; 7→2 (loop back); node 8 is the exit. What is V(G)?

  1. A. 4
  2. B. 3
  3. C. 5
  4. D. 2

Correct answer: A. 4

E = 10 and N = 8, so V(G) = 10 - 8 + 2 = 4. By predicates, a node with 3 exits counts as 2 decisions: node 2 gives 2, node 6 gives 1, so 3 + 1 = 4. Counting predicate nodes (2) and adding 1 gives the wrong 3.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic