Given a flow graph with 10 nodes, 13 edges and one connected components, the…
2013
Given a flow graph with 10 nodes, 13 edges and one connected components, the number of regions and the number of predicate (decision) nodes in the flow graph will be
- A.
4, 5
- B.
5, 4
- C.
3, 1
- D.
13, 8
Attempted by 76 students.
Show answer & explanation
Correct answer: B
Formula: V = E - N + 2P (cyclomatic complexity, which equals the number of regions for a connected flow graph).
Given: edges E = 13, nodes N = 10, connected components P = 1.
Compute the number of regions (cyclomatic complexity): V = 13 - 10 + 2*1 = 5.
Compute the number of predicate (decision) nodes: For a single connected flow graph, each decision increases V by 1, so predicate nodes = V - 1 = 5 - 1 = 4.
Answer: number of regions = 5, number of predicate (decision) nodes = 4.