Question: Software Testing & Validation Consider the following program that uses binary search to check whether the input array contains a specific input value. (4*5-20 points)

Software Testing & Validation

Software Testing & Validation Consider the following program that uses binary searchto check whether the input array contains a specific input value. (4*5-20

Consider the following program that uses binary search to check whether the input array contains a specific input value. (4*5-20 points) public class BinarySearch l public boolean containsCintl] a, int b) if (.length-0) { //bl(true), b2(false) s2 return false; int low-0; int high-a.length 1; S4 while Clowhigh) //b3Ctrue), b4Cfalse) int middle-Clow + high) / 2; if (b> a[middle])/b5(true), b6(false) s6 s8 S9 s10 s11 s12 low - middle 1; high-middle - 1; return true else if (b a[middle])/b7Ctrue), b8(false) else t S13 return false; a. Draw the control-flow graph of the program b. Complete the following coverage matrix for both statement (marked on the left side of the code) and branch coverage (marked on the right side of the code) of the following four tests: i. t1: a-1,2,3], b-2 ii. t2: a-1,2,3), b-1 ii. t3: a-[1,2,3], b-3 iv. t4: a-1,2,3], b-4 Consider the following program that uses binary search to check whether the input array contains a specific input value. (4*5-20 points) public class BinarySearch l public boolean containsCintl] a, int b) if (.length-0) { //bl(true), b2(false) s2 return false; int low-0; int high-a.length 1; S4 while Clowhigh) //b3Ctrue), b4Cfalse) int middle-Clow + high) / 2; if (b> a[middle])/b5(true), b6(false) s6 s8 S9 s10 s11 s12 low - middle 1; high-middle - 1; return true else if (b a[middle])/b7Ctrue), b8(false) else t S13 return false; a. Draw the control-flow graph of the program b. Complete the following coverage matrix for both statement (marked on the left side of the code) and branch coverage (marked on the right side of the code) of the following four tests: i. t1: a-1,2,3], b-2 ii. t2: a-1,2,3), b-1 ii. t3: a-[1,2,3], b-3 iv. t4: a-1,2,3], b-4

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!