Cyclomatic Complexity MCQs: 12 Independent-Path Questions Solved

Solve 12 cyclomatic complexity MCQs, then check each answer using edges, nodes, predicates, regions, or a second independent method.

KnowledgeGate Team

Exam prep & CS education

Updated 23 Nov 20267 min read
Cyclomatic Complexity MCQs: 12 Independent-Path Questions Solved

Formula recall is not enough when an MCQ switches among edges and nodes, predicates, regions, Boolean conditions, or integrated modules. Solve each item and write the arithmetic before reading its explanation. For related practice, use the Software Engineering module and the UGC NET CS Exam Preparation category; individual pages for these twelve questions are not currently available.

The three equivalent counts behind independent paths

Flow graph with nodes 1–6, equivalent cyclomatic formulas, worked counts, and three basis paths.

For a connected flow graph, use any of these equivalent forms:

  • V(G) = E - N + 2, where E is the edge count and N is the node count.

  • V(G) = P + 1, where P is the predicate-node count.

  • V(G) = number of regions, including the outside region.

An independent path adds at least one previously unused edge. V(G) is the size of a basis set, not every possible execution trace. See Software Engineering for CS Teaching Exams for the wider subject context.

For nodes 1, 2, 3, 4, 5, 6 and edges 1->2, 2->3, 2->4, 3->5, 4->5, 5->2, 5->6, we have N = 6, E = 7, and P = 2 from predicate nodes 2 and 5. Thus V = 7 - 6 + 2 = 3, also P + 1 = 2 + 1 = 3. A basis is 1-2-3-5-6, 1-2-4-5-6, and 1-2-3-5-2-4-5-6; the last path adds loop edge 5->2.

Foundations and formula recognition, Questions 1 to 3

Question 1 (ISRO 2025)

Cyclomatic complexity is associated with

A. White Box Testing

B. Black Box Testing

C. Grey Box Testing

D. None of the above

Answer: A. White Box Testing. Cyclomatic complexity measures internal control flow, so it is a white-box technique.

Question 2 (UGC NET 2014, December)

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

A. The number of regions – 1

B. E – N + 1, where E is the number of flow graph edges and N is the number of flow graph nodes.

C. P – 1, where P is the number of predicate nodes in the flow graph G.

D. P + 1, where P is the number of predicate nodes in the flow graph G.

Answer: D. If P = 3, then V = P + 1 = 4. The equivalent counts are four regions and E - N + 2, so the other formulas are off by one or reverse the terms.

Question 3 (UGC NET 2012, June)

Which one of the following statements is incorrect?

A. The number of regions corresponds to the cyclomatic complexity.

B. Cyclomatic complexity for a flow graph G is V(G) = N - E + 2, where E is the number of edges and N is the number of nodes in the flow graph.

C. Cyclomatic complexity for a flow graph G is V(G) = E - N + 2, where E is the number of edges and N is the number of nodes in the flow graph.

D. Cyclomatic complexity for a flow graph G is V(G) = P + 1, where P is the number of predicate nodes contained in the flow graph G.

Answer: B. It reverses the edge and node terms. With E = 9 and N = 7, the correct result is 9 - 7 + 2 = 4; the reversed expression gives the impossible value 0.

Calculate from edges, nodes, regions and predicates, Questions 4 to 5

Question 4 (ISRO 2013)

What is the cyclomatic complexity of a module which has seventeen edges and thirteen nodes?

A. 4

B. 5

C. 6

D. 7

Answer: C. Substitute directly: V = E - N + 2 = 17 - 13 + 2 = 6. A planar drawing has six regions; when every decision is binary, P = 5 also gives V = P + 1 = 6.

Question 5 (UGC NET 2013, December)

Given a flow graph with 10 nodes, 13 edges and one connected component, 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

Answer: B. V = 13 - 10 + 2 = 5, so there are five regions. Then P + 1 = 5, giving P = 4. In the requested order, the pair is (5, 4).

Count predicates in pseudocode, Questions 6 to 8

Question 6 (UGC NET 2012, June)

Consider the following pseudo-code:

If (A > B) and (C > D)

then A = A + 1

B = B + 1

The cyclomatic complexity of the pseudo-code is

A. 2

B. 3

C. 4

D. 5

Answer: B. Under short-circuit control flow, (A > B) and (C > D) are separate decisions. Thus P = 2 and V = P + 1 = 3; treating the whole condition as one predicate would miss a branch.

Question 7 (ISRO 2014)

Consider the following pseudo code

while (m < n)

if (x > y ) and (a < b) then

a=a+1

y=y-1

end if

m=m+1

end while

What is cyclomatic complexity of the above pseudo code?

A. 2

B. 3

C. 4

D. 5

Answer: C. Count while (m < n), (x > y), and (a < b): P = 3, so V = P + 1 = 4. Assignments create no decisions.

Question 8 (ISRO 2020)

Consider the following pseudo-code:

I = 0; J = 0; K = 8;

while (I < K – 1) //while-1

{

J = J + 1;

while (J < K) //while-2

{

if (x[I] < x[J])

{

temp = x[I];

x[I] = x[J];

x[J] = temp;

}

} // end of while-2

I = I +1;

} // end of while-1

The cyclomatic complexity of the above is

A. 3

B. 2

C. 4

D. 1

Answer: C. The decisions are while-1, while-2, and if. Hence P = 3 and V = 3 + 1 = 4; assignments and K = 8 do not affect the count.

Read one flow graph three ways, Questions 9 to 11

The source flow graph provides the structure needed to solve these questions.

!Flow graph F with entry node 1 and exit node 11

Question 9 (UGC NET 2019, December)

A flow graph F with entry node (1) and exit node (11) is shown below:

How many predicate nodes are there and what are their names?

A. Three: (1,(2,3),6)

B. Three: (1,4,6)

C. Four: ((2,3),6,10,11)

D. Four: ((2,3), 6,9,10)

Answer: A. Predicate nodes have multiple outgoing edges. Here they are 1, grouped node (2,3), and 6, so P = 3. Nodes 9, 10, and exit 11 are not predicates.

Question 10 (UGC NET 2019, December)

A flow graph F with entry node (1) and exit node (11) is shown below:

How many regions are there in flowgraph F?

A. 2

B. 3

C. 4

D. 5

Answer: C. Three bounded areas plus the outside region make four. Check with Question 9: V = P + 1 = 3 + 1 = 4.

Question 11 (UGC NET 2019, December)

A flow graph F with entry node (1) and exit node (11) is shown below:

What is the cyclomatic complexity of flowgraph F?

A. 2

B. 3

C. 4

D. 5

Answer: C. There are nine flow nodes and 11 directed edges, so V = 11 - 9 + 2 = 4. This matches three predicates plus one and four regions.

A basis is 1-(11), 1-(2,3)-(4,5)-10-1-11, 1-(2,3)-6-7-9-10-1-11, and 1-(2,3)-6-8-9-10-1-11. Each new path adds an unused edge.

Sequential integration changes the basis count, Question 12

Question 12 (ISRO 2017, May)

!Modules X and Y and their sequential integration

The cyclomatic complexity of each of the modules X and Y shown below is 10. What is the cyclomatic complexity of the sequential integration shown on the right hand side?

A. 21

B. 19

C. 20

D. 10

Answer: B. V(X) = V(Y) = 10 means each has nine predicates. Integration adds none, so P_total = 9 + 9 = 18 and V_total = 18 + 1 = 19. Equivalently, V(X followed by Y) = 10 + 10 - 1 = 19; subtract one for the shared straight-through path.

Answer key, error diagnosis and next practice step

The compact key is Q1 A, Q2 D, Q3 B, Q4 C, Q5 B, Q6 B, Q7 C, Q8 C, Q9 A, Q10 C, Q11 C, Q12 B.

Q1 tests white-box purpose; Q2 to Q5 test formula conversion; Q6 to Q8 test Boolean decisions; Q9 to Q11 test three graph counts; and Q12 tests sequential integration.

Retest Q4, Q5, Q7, and Q11 in six minutes. Your results should be 6, (5 regions, 4 predicates), 4, and 4. Continue with NTA-UGC-NET Paper - 2 and the NTA UGC NET Paper - 2 Test Series.

Use the given representation, compute one equivalent form, and cross-check with another before choosing the option.