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> 求得n1,N1,n2,N2n_1, N_1, n_2, N_2
operator Number of Occurrences
if 1
dayray 1
return 1
< 1
+= 1
- 1
+ 6
* 2
/ 4
% 1

n1=10,n2=19n_1 = 10, n_2 = 19

operand Number of Occurences
month 3
year 5
day 1
3 1
12 1
1 1
26 1
10 1
4 1
6 1
100 1
400 1
7 1

n2=13,N2=19n_2 = 13, N_2 = 19

  • 2> 求11項值
指標
程序詞彙表長度
Program vocabulary
n=n1+n2n = n_1 + n_2
=10+13=23= 10 + 13 = 23
程序長度
Program length
N=N1+N2N = N_1 + N_2
=19+19=38= 19 + 19 = 38
程序的預測長度
Calculated program length
N^=n1log2n1+n2log2n2\hat N = n_1\log_{2}{n_1} + n_2\log_{2}{n_2}
=10log210+13log213= 10 \cdot \log_{2}{10} + 13 \cdot \log_{2}{13}
33.22+48.11=81.33\approx 33.22 + 48.11 = 81.33
程序體積
Volume
V=Nlog2nV = N\log_{2}{n}
=38log223171.90= 38\cdot\log_{2}{23} \approx 171.90
程序級別
Level
L^=2n1×n2N2\hat L = \frac{2}{n_1} \times\frac{n_2}{N_2}
=210×13190.136842=\frac{2}{10} \times \frac{13}{19} \approx 0.136842
程序難度
Difficulty
D=1L^7.31D = \frac{1}{\hat L}\approx7.31
編程工作量
Effort
E=V×D=VL^E = V \times D = \frac{V}{\hat L}
=38log223261901,256.16= \frac{38\cdot\log_{2}{23}}{\frac{26}{190}}\approx1,256.16
語言級別 L=L^×L^×V0.08471L{&#x27;} = \hat L \times \hat L \times V\approx 0.08471
編程時間
hours
T^=ES×f,S=60×60,f=18\hat T = \frac{E}{S\times f}, S = 60 \times 60, f = 18
T^0.019385\hat T\approx 0.019385
平均語句大小 N=384=9.5\frac{N}{語句數} = \frac{38}{4} = 9.5
程序中的錯誤數預測值 B=V3000=Nlog2n3000B = \frac{V}{3000} = \frac{N\log_{2}{n}}{3000}
=38log22330000.057298= \frac{38\cdot \log_{2}{23}}{3000} \approx 0.057298
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章