Question: Building a Flow Graph and Calculating Cyclomatic Complexity, V(G) When you are doing white box testing, I am a strong proponent of doing cyclomatic complexity

Building a Flow Graph and Calculating Cyclomatic Complexity, V(G)

When you are doing white box testing, I am a strong proponent of doing cyclomatic complexity calculations and basis path testing, provided you have the time to do so. Since it guarantees complete statement and branch coverage, basis path testing gives you an absolute minimum number of test cases you should run for any given code fragment. This question is an exercise in constructing a flow graph and calculating the cyclomatic complexity of a code fragment.

What you need to do:

For the code fragment shown below, do the following:

  1. Construct a flow graph for the code.
  2. From your flow graph, calculate the cyclomatic complexity, V(G) . The code is written in Java.

private void downShift(int index) { // index of "child", which will be either index * 2 or index * 2 + 1 int childIndex; // temp storage for item at index where shifting begins Comparable temp = theItems[index]; // shift items, as needed while (index * 2 <= theSize) { // set childIndex to "left" child childIndex = index * 2; // move to "right" child if "right" child < "left" child if (childIndex != theSize && theItems[childIndex + 1].compareTo(theItems[childIndex]) < 0) childIndex++; if (theItems[childIndex].compareTo(temp) < 0) { // shift "child" down if child < temp theItems[index] = theItems[childIndex]; } else { // shifting complete break; } // increment index index = childIndex; } // position item that was originally at index where shifting began theItems[index] = temp; }

What you need :
  1. Your flow graph
  2. Your 3 V(G) calculations.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!