Which of the following statements is correct?

Consider the following control flow graph:

The control flow represents a software component of a car navigation system. Within the project the maximum cyclomatic complexity to be allowed is set at 5.

Which of the following statements is correct?
A . No defect needs to be reported since the cyclomatic complexity of the component is calculated at 3.
B . No defect needs to be reported since the cyclomatic complexity of the component is calculated at 4
C . No defect needs to be reported since the cyclomatic complexity of the component is calculated at 5.
D . A defect needs to be reported since the cyclomatic complexity of the component is calculated at 6.

Answer: D

Explanation:

Cyclomatic complexity is a measure of the number of linearly-independent paths through a program’s source code, which is often used as a measure of the complexity of a program. The control flow graph provided represents the logic of a software component and has more than 5 nodes with decision points, indicating that the complexity would exceed the maximum allowed value of 5. The calculation for cyclomatic complexity is V(G) = E – N + 2P, where E is the number of edges, N is the number of nodes, and P is the number of connected components. In this case, the calculated cyclomatic complexity exceeds the allowed threshold, thus a defect should be reported.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments