A = A + 1
B = B + 1
Endif
The cyclomatic complexity of the pseudo-code is
Options (A) 2 (B) 3 (C) 4 (D) 5
Answer (A) 2.
Explanations.
Let line no 1 is If (A > B) and (C > D) then. Line no 2 is A = A + 1 ,B = B + 1 Line no 3 is end if. Line no 4 is rest of program. Its flow graph is I Mathematically, it is set of independent paths. The complexity of the program can be defined as -
V(G) = E - N + 2
Where, E - Number of edges N - Number of Nodes
V (G) = P + 1
Where P = Number of predicate nodes (node that contains condition). in our case E=4, and n=4 then V(G)= E-N+2= 2. So cyclomatic complexity is 2.
It has two independent paths 1-4, and 1-2-3-4. Hence cyclomatic complexity is 2.
It has two regions.one is inner region and one is outer hence cyclomatic complexity is 2.
It has one predicate node so P+1=2 so cyclomatic complexity is 2.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.