retagged by
3,203 views
2 votes
2 votes

Which one of the following is used to compute cyclomatic complexity ?

  1. The number of regions $-1$ 
  2. $E – N + 1$, where $E$ is the number of flow graph edges and $N$ is the number of flow graph nodes.
  3. $P – 1$, where $P$ is the number of predicate nodes in the flow graph $G$. 
  4. $P + 1$, where $P$ is the number of predicate nodes in the flow graph $G$. 
retagged by

1 Answer

Best answer
1 votes
1 votes

Cyclomatic complexity is a metric to measure logical complexity of a program.

  • Cyclomatic complexity defines the number of independent paths in a program
  • It gives an upper bound for the number of tests that must be conducted to ensure that all statements have been executed at least once
  • An independent path is any path through the program that introduces at least one new set of processing statements or a new condition.     

Cyclomatic complexity is computed in one of three ways:

1. The number of regions of the flow graph
2. Cyclomatic complexity, V(G), for a flow graph, G, is defined as V(G) = E - N+ 2k where E is the number of flow graph edges, N is the number of flow graph nodes and k is the number of connected components or number of exit points.

3. V(G) = P+ 1 where P is the number of predicate (condition) nodes contained in the flow graph G.

Answer (D)

selected by
Answer:

Related questions

1 votes
1 votes
2 answers
1
1 votes
1 votes
1 answer
3
1 votes
1 votes
2 answers
4