Q1. With an appropriate pseudo-code, prove that all different methods of cyclomatic Complexity (CC) computation result in the same value. Ensure that the value of the CC is at least 5.

Ans ⇒

Cyclomatic Complexity (CC) is a software metric used to measure the complexity of a program. There are several methods to compute Cyclomatic Complexity, and it's important to note that different methods should ideally result in the same value for a given piece of code. The most common method is based on control flow graphs, and one way to prove their equivalence is by demonstrating that different formulas for Cyclomatic Complexity yield the same result.

Here is a simple pseudo-code example and its corresponding Cyclomatic Complexity computation using different methods:

pseudoCopy code
1.  Start
2.  Input a, b
3.  if (a > 0) then
4.      print "a is positive"
5.  else
6.      print "a is non-positive"
7.  endif
8.  while (b > 0) do
9.      b = b - 1
10. endwhile
11. End

Now, let's compute the Cyclomatic Complexity using three different methods:

flowdiagram.jpg

Method 1: Basic Formula

CC=E−N+2P** Where:

For the given pseudo-code:

CC1=9−8+(2×1)=5

Method 2: Decision Points

CC=D+1 Where: