📜  门| GATE-CS-2015(套装3)|第 65 题

📅  最后修改于: 2021-09-26 04:12:55             🧑  作者: Mango

考虑三个软件项:Program-X、Program-Y的控制流程图和Program-Z的控制流程图如下所示
Q65
Program-X、Program-Y 和 Program-Z 的 McCabe 圈复杂度的值分别为
(一) 4, 4, 7
(B) 3、4、7
(C) 4、4、8
(四) 4, 3, 8答案:(一)
解释:

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

这个问题的测验