Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding the function complexity index

I have to find the complexity of a C file based on the number of lines. I have found the number of lines. But how to decide whether it is a complex file or not? Based on certain value, I have to give it an index. For eg., complexity index - 5 for high complexity. On which basis can I index it? More than 1000 lines for high complex, for eg., won't apply for all. Is there any standard way for giving conditions('more than 1000 lines')? Any kind of suggestions are welcome, except any pre-defined tools. I need to program it in C. Thanks in advance.

like image 388
Gomathi Avatar asked Mar 11 '26 23:03

Gomathi


1 Answers

comlexity is not based on lines, for example:

while(n!=0) {a+=b;n--;}

the complex is n and another exapmle:

for(i=0;i<n;i++) {for(j=0;j<n;j++) {a+=b} }

the complexity is n^2

like image 57
shimon Avatar answered Mar 13 '26 12:03

shimon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!