Back to the 2026 paper

Module 3: Software Design & Metrics

20262m

Cyclomatic complexity of a connected control-flow graph with E edges, N nodes and P connected components is

(i) E+N+P
(ii) E-N-P
(iii) N-E+2P
(iv) E-N+2P

Worked SolutionAI Assisted

Solution

Correct Answer: (iv) E - N + 2P

Explanation

McCabe's cyclomatic complexity of a control-flow graph with E edges, N nodes and P connected components is:

V(G) = E - N + 2P

For a single connected program (P = 1) this becomes V(G) = E - N + 2. It also equals:

  • number of predicate (decision) nodes + 1
  • number of regions in the planar graph

It gives the number of linearly independent paths, i.e. the minimum number of test cases for branch coverage.

Why other options are incorrect:

  • (i) E+N+P, (ii) E-N-P, (iii) N-E+2P - not valid forms of the formula.

Answer: (iv) E - N + 2P

Similar questions

AI LearningWeb Platform

Coursify — Personal AI Course Generator

Struggling with a difficult subject or concept? Turn any engineering topic into a structured course with interactive lessons, quizzes, and research-backed explanations.