Question: Consider the following program that uses binary search to check whether the input array contains a speci c input value, and the 4 tests, and

Consider the following program that uses binary search to check whether the input array contains a speci c input value, and the 4 tests, and answer the following questions.


t1:{1,2,3}, 2

t2:{1,2,3}, 1

t3:{1,2,3} ,3

t4:{1,2,3}, 4

public class BinarySearch { sl s2 s3 s4 s5 s6 s7 s8



  1. Draw the control flow graph for the program.

  1. Compute the statement and branch coverage for each test.

  1. Provide the order of tests with the total strategy.

  1. Provide the order of tests with the additional strategy.


 

public class BinarySearch { sl s2 s3 s4 s5 s6 s7 s8 s9 s10 sll s12 s13 } public boolean contains (int[] a, int b) { } if (a.length == 0) { //bl(true), b2(false) return false; } int low = 0; int high = a.length - I; while (low a[middle]) { //b5(true), b6(false) low = middle + I; } else if (b < a[middle]) { //b7(true), b8(false) high = middle - I; } else { } return false; return true;

Step by Step Solution

3.27 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Control flow graph Start if alength 0 return false if alength 0 while low if b ... View full answer

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!