Question: The Java method below calculates the greatest common divisor of two integers ( num 1 , num 2 ) . The valid input range of

The Java method below calculates the greatest common divisor of two integers (num 1, num2).
The valid input range of num 1 and num 2 is specified as follows:
0\leqnum1\leq100000\leqnum2\leq5000
public static int gcd(int num1, int num2){
int a = num1;
int b = num2;
if (a0|| b0|| a>10000|| b >5000)
l
System.out.println("Invalid input");
return -1;
} else {
int i =0;
while (a !=0){
++i;
int temp = a;
a = b % a;
b = temp;v
}
System.out.println("GCD Calculation required "+
i +" iterations");
return b;
}
a) Draw the corresponding Control Flow Graph and label the nodes of the CFG with the respective line numbers in the source code. [7 points]
b) Draw the prime decomposition tree. [4 points]
c) How many test cases are needed (at a minimum) to achieve the following coverage criteria? Please list the identified test cases [4 points]
Simple path coverage
Basis path coverage
d) Provide provide all (partial) paths to achieve all DU-path coverage with respect to variable'a. All paths should be defined in terms of nodes traversed in the CFG.[4 points]
e) Create the following backward slice $ (fb},16). Simply list the line numbers of the statementsto be included in the slice. [4 points]
The Java method below calculates the greatest

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 Programming Questions!