STMT Assignment 4

STMT Assignment 4

方向:计算机应用

学号:16340227

姓名:王永杰


1 计算题


1.1 计算下列代码片段的Halstead 复杂度的11项内容:

if (month < 3) { 
    month += 12;
    –year; 
} 
return dayray((int)(day + (month + 1) * 26/10 + year + year/4 + 6 * (year/100) + year/400)% 7); 
  • Sol:
  • 1> 求得 n 1 , N 1 , n 2 , N 2 n_1, N_1, n_2, N_2 n1,N1,n2,N2
operatorNumber of Occurrences
if1
dayray1
return1
<1
+=1
-1
+6
*2
/4
%1

n 1 = 10 , n 2 = 19 n_1 = 10, n_2 = 19 n1=10,n2=19

operandNumber of Occurences
month3
year5
day1
31
121
11
261
101
41
61
1001
4001
71

n 2 = 13 , N 2 = 19 n_2 = 13, N_2 = 19 n2=13,N2=19

  • 2> 求11项值
指标
程序词汇表长度
Program vocabulary
n = n 1 + n 2 n = n_1 + n_2 n=n1+n2
= 10 + 13 = 23 = 10 + 13 = 23 =10+13=23
程序长度
Program length
N = N 1 + N 2 N = N_1 + N_2 N=N1+N2
= 19 + 19 = 38 = 19 + 19 = 38 =19+19=38
程序的预测长度
Calculated program length
N ^ = n 1 log ⁡ 2 n 1 + n 2 log ⁡ 2 n 2 \hat N = n_1\log_{2}{n_1} + n_2\log_{2}{n_2} N^=n1log2n1+n2log2n2
= 10 ⋅ log ⁡ 2 10 + 13 ⋅ log ⁡ 2 13 = 10 \cdot \log_{2}{10} + 13 \cdot \log_{2}{13} =10log210+13log213
≈ 33.22 + 48.11 = 81.33 \approx 33.22 + 48.11 = 81.33 33.22+48.11=81.33
程序体积
Volume
V = N log ⁡ 2 n V = N\log_{2}{n} V=Nlog2n
= 38 ⋅ log ⁡ 2 23 ≈ 171.90 = 38\cdot\log_{2}{23} \approx 171.90 =38log223171.90
程序级别
Level
L ^ = 2 n 1 × n 2 N 2 \hat L = \frac{2}{n_1} \times\frac{n_2}{N_2} L^=n12×N2n2
= 2 10 × 13 19 ≈ 0.136842 =\frac{2}{10} \times \frac{13}{19} \approx 0.136842 =102×19130.136842
程序难度
Difficulty
D = 1 L ^ ≈ 7.31 D = \frac{1}{\hat L}\approx7.31 D=L^17.31
编程工作量
Effort
E = V × D = V L ^ E = V \times D = \frac{V}{\hat L} E=V×D=L^V
= 38 ⋅ log ⁡ 2 23 26 190 ≈ 1 , 256.16 = \frac{38\cdot\log_{2}{23}}{\frac{26}{190}}\approx1,256.16 =1902638log2231,256.16
语言级别 L ′ = L ^ × L ^ × V ≈ 0.08471 L{&#x27;} = \hat L \times \hat L \times V\approx 0.08471 L=L^×L^×V0.08471
编程时间
hours
T ^ = E S × f , S = 60 × 60 , f = 18 \hat T = \frac{E}{S\times f}, S = 60 \times 60, f = 18 T^=S×fE,S=60×60,f=18
T ^ ≈ 0.019385 \hat T\approx 0.019385 T^0.019385
平均语句大小 N 语 句 数 = 38 4 = 9.5 \frac{N}{语句数} = \frac{38}{4} = 9.5 N=438=9.5
程序中的错误数预测值 B = V 3000 = N log ⁡ 2 n 3000 B = \frac{V}{3000} = \frac{N\log_{2}{n}}{3000} B=3000V=3000Nlog2n
= 38 ⋅ log ⁡ 2 23 3000 ≈ 0.057298 = \frac{38\cdot \log_{2}{23}}{3000} \approx 0.057298 =300038log2230.057298
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值