Cyclomatic-metric

Question 1

Consider the following C program segment.

while (first <= last)
{
   if (array [middle] < search)
      first = middle +1;
   else if (array [middle] == search)
      found = True;
   else last = middle – 1;
   middle = (first + last)/2;
}
if (first < last) not Present = True;

The cyclomatic complexity of the program segment is __________.

A
5
B
6
C
7
D
8
Question 1 Explanation: 
Note: Out of syllabus.
Question 2

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


A
19
B
21
C
20
D
10
Question 2 Explanation: 
Note: Out of syllabus.
Question 3
    I. The cyclomatic complexity of a module is equal to the maximum number of linearly independent circuits in the graph.

    II. The cyclomatic complexity of a module is the number of decisions in the module plus one, where a decision is effectively any conditional statement in the module.

    III. The cyclomatic complexity can also be used as a number of linearly independent paths that should be tested during path coverage testing.
A
I and II
B
II and III
C
I and III
D
I, II and III
Question 3 Explanation: 
Note: Out of syllabus. [Software Engineering]
Question 4

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 4 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.
There are 4 questions to complete.

Access quiz wise question and answers by becoming as a solutions adda PRO SUBSCRIBER with Ad-Free content

Register Now

If you have registered and made your payment please contact solutionsadda.in@gmail.com to get access