Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 homework is an exercise in constructing a flow graph and calculating the cyclomatic complexity of a code fragment.

What needs to be done

For the code fragment shown below, do the following:

Construct a flow graph for the code. You may do this in any way that allows you to send it to me in digital format. You can create the graph using Visio, Word, or some other application. You can also draw it on paper and scan it in - just make sure it's clearly readable.

From your flow graph, calculate the cyclomatic complexity, V(G), using all three of the methods discussed in class. All three calculations should agree with each other.

The code is written in Java, so you are all probably familiar with the syntax to some extent. In the event you are unable to follow the syntax, please let me know. You needn't be concerned with what the code itself is supposed to do.

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 needs to be turned in

Your flow graph in one of the following formats:

Visio document (.vsd)

Word or Rich Text document (.doc, .rtf)

JPEG or GIF image (.jpg, .gif)

Your 3 V(G) calculations

correct number of nodes is 13

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Logidata+ Deductive Databases With Complex Objects Lncs 701

Authors: Paolo Atzeni

1st Edition

354056974X, 978-3540569749

More Books

Students also viewed these Databases questions