October 5, 2023
October 5, 2023
October 5, 2023
###### Software-Engineering
October 5, 2023
 Question 27

Consider the following pseudo-code:

``` IF ((A > B) AND (C > D)) THEN
A = A + 1
B = B + 1
ENDIF
```

The cyclomatic complexity of the pseudo-code is

 A 2 B 3 C 4 D 5
Question 27 Explanation:
The cyclomatic complexity of a program can be calculated using the formula:

V(G) = E – N + 2P

Where:

V(G) is the cyclomatic complexity.
E is the number of edges in the control flow graph.
N is the number of nodes in the control flow graph.
P is the number of connected components (usually 1).
In your pseudo code, there are two conditional statements (A > B and C > D), and an “ENDIF” which represents the end of the conditional block. This forms a basic control flow structure.

Let’s break it down into a control flow graph:

Start (Node 1)
Condition A > B (Node 2)
Condition C > D (Node 3)
A = A + 1 (Node 4)
B = B + 1 (Node 5)
EndIF (Node 6)
Now, count the number of edges (E) and nodes (N):

E = 7 (7 transitions between nodes)
N = 6 (6 nodes)
Since there is only one connected component (P = 1), we have:

V(G) = E – N + 2P = 7 – 6 + 2 * 1 = 3

So, the cyclomatic complexity of your pseudo code is 3.

Question 27 Explanation:
The cyclomatic complexity of a program can be calculated using the formula:

V(G) = E – N + 2P

Where:

V(G) is the cyclomatic complexity.
E is the number of edges in the control flow graph.
N is the number of nodes in the control flow graph.
P is the number of connected components (usually 1).
In your pseudo code, there are two conditional statements (A > B and C > D), and an “ENDIF” which represents the end of the conditional block. This forms a basic control flow structure.

Let’s break it down into a control flow graph:

Start (Node 1)
Condition A > B (Node 2)
Condition C > D (Node 3)
A = A + 1 (Node 4)
B = B + 1 (Node 5)
EndIF (Node 6)
Now, count the number of edges (E) and nodes (N):

E = 7 (7 transitions between nodes)
N = 6 (6 nodes)
Since there is only one connected component (P = 1), we have:

V(G) = E – N + 2P = 7 – 6 + 2 * 1 = 3

So, the cyclomatic complexity of your pseudo code is 3.

Article Rating
Subscribe
Notify of