Halstead complexity measures: Difference between revisions

Content deleted Content added
added an example
Line 29:
Halstead's delivered bugs (B) is an estimate for the number of errors in the implementation.
*Number of delivered bugs : <math>B = {E^{2 \over 3} \over 3000}</math> or, more recently, <math>B = {V \over 3000}</math> is accepted {{Citation needed||reason='By whom?'|date=August 2013}}.
 
== Example ==
 
Let us consider the following C program:
 
<code>
main( )
{
int a, b, c, avg;
scanf(“%d %d %d”, &a, &b, &c);
avg = (a+b+c)/3;
printf(“avg = %d”, avg);
}
</code>
The unique operators are:
main,(),{},int,scanf,&,“,”,“;”,=,+,/, printf
The unique operands are:
a, b, c, &a, &b, &c, a+b+c, avg, 3, “%d %d %d”, “avg = %d”
Therefore,
<math>\,\eta_1</math> = 12, <math>\,\eta_2</math> = 11
Estimated Length = (12*log<sub>2</sub>12 + 11*log<sub>2</sub>11) = (12*3.58 + 11*3.45) = (43+38) = 81
Volume = Length*log(23) = 81*4.52 = 366
 
==References==