CS FundamentalsHardGATE CS · Software Engineering · Advanced

The control-flow graphs of a program's two separate routines have E = 16, N = 13 and E = 9, N = 8 edges and nodes respectively (each graph has one entry and one exit and is connected, and the routines are not linked by call edges). By McCabe's formula V(G) = E - N + 2P applied to the combined graph with P connected components, how many linearly independent paths does the program have in total, and what is the V(G) of the larger routine alone?

  1. A. 8 in total, 5 for the larger routine
  2. B. 8 in total, 4 for the larger routine
  3. C. 6 in total, 5 for the larger routine
  4. D. 10 in total, 5 for the larger routine

Correct answer: A. 8 in total, 5 for the larger routine

Combined: E = 25, N = 21, P = 2, so V = 25 - 21 + 4 = 8, which equals the sum of the routines' own values (5 + 3). The larger routine alone has 16 - 13 + 2 = 5. Using P = 1 for the combined graph undercounts by 1.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic