search
Log In
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
5 votes
2.2k views

Consider the following software items: Program-$X$, Control Flow Diagram of Program-$Y$ and Control Flow Diagram of Program-$Z$ as shown below

The values of McCabe's Cyclomatic complexity of program-$X$, program-$Y$, and program-$Z$ respectively are

  1. 4, 4, 7
  2. 3, 4, 7
  3. 4, 4, 8
  4. 4, 3, 8
in IS&Software Engineering
retagged by
2.2k views

4 Answers

14 votes
 
Best answer

cyclomatic complexity = no of predicate nodes +1

No of predicate nodes = decision making nodes

so for program X , no of predicate nodes = 3 (if, while , if )

cyclomatic complexity of program X = 3+1=4

For program Y, no of predicate nodes = 3 ( node3, node6, node8)

cyclomatic complexity for program Y = 3+ 1=4

For program Z , no of predicate nodes = 6 ( 3 of X followed by 3 of Y)

cyclomatic complexity of Z = 6+1 =7


selected by
1
@praveen sir, inside the $while$ there are two conditions to be evaluated i.e. $i<value$ and $result <=maxint$..then why we are not considering as two decision making nodes?
1
because both the conditions combined will lead to any branch...
0
Sir how can the node 8 in Y be a predicate node.. because there is only 1 outgoing edge for it...
0
node 8 should have another outgoing edge as final node
6 votes

With reference to the article http://www.chambers.com.au/glossary/mc_cabe_cyclomatic_complexity.php
McCabe's Cyclomatic complexity is =E-N+2P where E=no of edge, N=no of node and P= no of disconnected graph.
for program x, E=11, N=9, P=1 so MCC=E-N+2P=11-9+1*2=4
for program y, E=10, N=8, p=1 so MCC=10-8+1*2=4
for program z, E=22, N=17, p=1 so MCC= 22-17+1*2=7
 so answer is A(4,4,7).

 

1 vote
answer is A.
0 votes

The cyclomatic complexity of a structured program[a] is defined
with reference to the control flow graph of the program, a directed
graph containing the basic blocks of the program, with an edge
between two basic blocks if control may pass from the first to the
second. The complexity M is then defined as.

    M = E − N + 2P,

where

    E = the number of edges of the graph.
    N = the number of nodes of the graph.
    P = the number of connected components. 

Source: http://en.wikipedia.org/wiki/Cyclomatic_complexity

For first program X, E = 11, N = 9, P = 1,  So M = 11-9+2*1 = 4
For second program Y, E = 10, N = 8, p = 1, So M = 10-8+2*1 = 4
For Third program X, E = 22, N = 17, p = 1, So M = 22-17+2*1 = 7

Answer:

Related questions

2 votes
2 answers
1
1.6k views
Consider a software project with the following information domain characteristics for calculation of function point metric. Number of external inputs (I) = 30 Number of external outputs (O) = 60 Number of external inquiries (E) = 23 Number of files (F) = 08 ... four factors have value 3, and each of the remaining factors have value 4. The computed value of function point metric is _________.
asked Feb 14, 2015 in IS&Software Engineering jothee 1.6k views
2 votes
1 answer
2
1.8k views
Consider a software program that is artificially seeded with 100 faults. While testing this program, 159 faults are detected, out of which 75 faults are from those artificially seeded faults. Assuming that both real and seeded faults are of same nature and have same distribution, the estimated number of undetected real faults is _______.
asked Feb 14, 2015 in IS&Software Engineering jothee 1.8k views
5 votes
4 answers
3
2.8k views
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 2 3 4 5
asked Oct 30, 2014 in IS&Software Engineering Ishrat Jahan 2.8k views
8 votes
3 answers
4
3.3k views
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) notpresent = TRUE; The cyclomatic complexity of the program segment is_______________.
asked Feb 13, 2015 in IS&Software Engineering makhdoom ghaya 3.3k views
...