Consider the following method
1. double calculateMin(int A, int B){
2. int minVal = A;
3. if (B<A){
4. minVal = B;
5. }
6. return minVal; 7.
7. }
Describe two mutation operators and use them to create two mutants.
First mutation operators can be operands A and B
First mutant if where we interchange operand A and B as below
double calculateMin(int A, int B){
int minVal = A;
if (A<B){
minVal = B;
}
return minVal;
}
The above code will now always return the largest of the two numbers A and B as such the test case will fail
=====================================================================================
Second mutation operators can be B<A, here we change less
than operator to greater than operator
double calculateMin(int A, int B){
int minVal = A;
if (B>A){
minVal = B;
}
return minVal;
}
The above code will now always return the largest of the two numbers A and B as such the test case will fail
Consider the following method 1. double calculateMin(int A, int B){ 2. int minVal = A; 3....
Consider the following method 1. double calculateMin(int A, int B){ 2. int minVal = A; 3. if (B<A){ 4. minVal = B; 5. } 6. return minVal; 7. 7. } Describe two mutation operators and use them to create two mutants.
2) Consider the following C function: ----------------------------------------------------------------------------- int vdiv(double * a, double * b, double *c, int siz) {// divide vectors element-wise: c=a/b; // replaces divide by almost 0 with 1e99 and returns count int result=0; int i=0; 1: while(i<siz) 2: { if( abs(b[i])<1e-10 ){ // close to 0 3: c[i]=1e99; 4: result++; 5: }else{ 6: c[i]=a[i]/b[i]; 7: } 8: i++; 9: } 10: return result; } -------------------------------------------------------------------------- Executable lines are numbered. -Find all basic blocks, -draw control flow graph...
Consider the following methods’ headers: public static int one(int a, char b, double c, String d) public static double two(double x, double y) public static char three(int r, int s, char t, double u) Answer the following questions: Q1) What is the signature of method one? Answer: Q2) What is the return type of method two? Answer: Q3) What the formal parameters of method three? Answer: Q4) How many actual parameters are needed to call the method three? Answer: Q5)...
Consider the following code: 1. float foo (int a, int b, int c, int d, float e) { 2. float e; 3. if (a == 0) { 4. return 0; 5. } 6. int x = 0; 7. if ((a==b) || ((c == d) && bug(a) )) { 8. x=1; 9. } 10. e = 1/x; 11. return e; 12. } Function bug(a) should return a value of true when passed a value of a=1. Build: • a test suite...
Consider the following code segment. int[]arr={1, 2, 3, 4, 5, 6, 7, 8}; for(int k=3; k<arr.length-1; R++ arr[k]-arr[k+1]; What are the contents of arr as a result of executing the code segment? a. {1, 2, 3, 5, 6, 7, 8, 8) b. {2, 2, 4, 5, 6, 7, 8, 8} C. {2, 4, 6, 5, 6, 7, 8,8} d. {4, 2, 4, 4, 6, 7, 8, 8) e. {6, 6, 4, 5, 6, 7, 8, 8} int) arr={7, 2.5, 3.0,...
D Question 3 For the following question, assume that int[] = {6, 2, 4, 5, 2, 1, 6, 2, 5) and consider the recursive method foo" public int foo(int[], int b, int 1) { if ( < length) { if (*[3] !- b) return foo(a, b, +1); else return foo(a, b, 3+1) + 1; }else return ; What is the result of calling foo(a, 3,0);? 0 1 02 3 00
Consider the following method. public static ArrayList<Integer mystery(int n) ArrayList<Integer seg - new ArrayList<IntegerO; for (int k = n; k > 0; k--) seq.add(new Integer(k+3)); return seq What is the final output of the following Java statement? System.out.println(mystery(3)); a. [1,2,4,5) b. [2,3,4,5) c. [6,5,4,3] d. [7, 7, 8, 8] e. [7,8,9, 8) O Consider the following method: public static int mystery(int[] arr, int k) ifk-0) return 0; }else{ return arr[k - 1] + mystery(arr, k-1):) The code segment below is...
on 2 Consider the following recursive method test: public static int test(String s, int last) if (last < 0) { return 0; if (s.charAt(last) == 0) { return 2 - test(s, last - 1); return 1 + 2 test(s, last - 1); What is the output of: test("11001", 4). TTT Arial 3 (12pt) - TEE 25
Double any element's value that is less than minVal. Ex: If minVal = 10, then dataPoints = {2, 12, 9, 20} becomes {4, 12, 18, 20}. #include <stdio.h> int main(void) { const int NUM_POINTS = 4; int dataPoints[NUM_POINTS]; int minVal; int i; dataPoints[0] = 2; dataPoints[1] = 12; dataPoints[2] = 9; dataPoints[3] = 20; minVal = 10; /* Your solution goes here */ for (i = 0; i < NUM_POINTS; ++i) { printf("%d ", dataPoints[i]); } printf("\n"); return 0; }