--- Video Title: Halstead’s Complexity Measures Description: Halstead’s Complexity Measures Watch more Videos at https://www.tutorialspoint.com/videotutorials/index.htm Lecture By: Mr. Arnab Chakraborty, Tutorials Point India Private Limited --- Hulstead's complexity measures. So, in this session, we are discussing the respective method to calculate the complexity and also we shall explain it with a proper example. So, in the year 1977, Mr. Maurice Howard Hulstead introduced metrics to measure software complexity. Hulstead's metrics depends upon the actual implementation of the program and it measures which are computed directly from the operators and the operands from the source code in static manner. It allows to evaluate testing time, vocabulary, size, difficulty, errors, efforts for this C, C++ or Java source codes. So, now, let us go for further detailing. So, according to the Hulstead, a computer program is an implementation of an algorithm considered to be a collection of tokens which can be classified either in the category of operators or operands. Hulstead metrics think a program. Hulstead metrics think a program as sequence of operators and their associated operands. So, here we are having one table. So, he defines various indicators to check complexity of a module. So, following table states the parameters and the respective meaning. So, small n1 that means the number of unique operators. We are considering here unique operators. Small n2, it is denoting number of unique operands. Capital n1, it is denoting number of total occurrence of operators. And capital N2 is denoting the number of total occurrence of the operands. So, small n1 is calculating the total number of unique operators. Small n2 is denoting the total number of unique operands. And this capital N1 and capital N2, they are denoting the total number of What occurrences of operators and operands respectively? When we select source file to view its complexity details in metric viewer, the following result is seen in the metric report. So, here we are having the respective different meaning, the metrics are there, meanings are there, and the mathematical representation. So, small n will be denoting the vocabulary which is nothing but n1 plus n2. That is small n1 plus small n2. Capital n will be denoting the size, which is nothing but n1 plus n2. Capital n1 plus capital n2. V stands for volume, which is length into log of vocabulary to the base 2. D stands for difficulty. These are respective expressions. We are having effort. We are having this B. We are having this T. So, the respective things have got expressed in the proper formula, in the proper mathematical representation. So, let us take one example for the better understanding. So, here we have taken one sample C code. Now, if you judge this particular C code, you can find that the unique operators are main, the first packet opening and closing, the second packet opening and closing, int scanf ampersand is equal to plus slash printf, we are having this comma and also the semicolon. So, if you go on counting, if you go on counting, you will be getting here total number of unique appearance, operator will be 12. Now, in case of total number of unique appearance, so if you look at this particular program segment, you can find that these are the respective appearance we are having. So, that is small a, small b, small c, a, b, g. This is the one string and then 3 and there is another string is there. So, here if you go on counting, we are getting this one 1, 2, 3, 4, 5, 6, 7. So, n 2 has become 7 here. So, what is n? N means small n 1 plus small n 2. What does it signify? It signifies the vocabulary. So, if you go on adding them, that is 12 plus 7, you are getting this 19, which is actually denoting the vocabulary. Next one, we are going to calculate that how many times these respective operators have occurred. So, here we are finding this one that these are the distinct operators and if you go on counting their occurrences, we are getting this one as 27 and n 2 is actually denoting the total number of appearance in this sample code that is 15. So, if you go on adding, we are getting this one 42. So, what was our capital N 1 plus capital N 2. So, that is our size. So, capital N 1 plus capital N 2 was our size and previously it was our vocabulary. So, that is why you have written this one as vocabulary and here is a size. Also, it is known as program length. So, calculated estimated program length is having this respective expression if you evaluate, you are getting this value that is 62.67. So, now how to calculate the volume? If you come to the previous slide, you are having this 1 there is the length into log of vocabulary to the base 2. So, that is the formula if you can remember this 1 we will then seen that we have put the respective values there that is the log of 19 to the base 2 and 19 here is a vocabulary you are getting to this one. So, now we are going to calculate the respective difficulty. So, here you can find these formulas are given. So, according to this formula, we have put the respective values and we have calculated it is a difficulty, effort, time required to program and number of delivered bugs. So, in this way, this is the Halstead's complexity measures. We have explained this one. What are the different calculations? What are the different mathematical expressions? And also, we have explained our discussion with one example. Thanks for watching this video. Simply easy learning.