Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
- Draw the control flow graph for the program.
- Compute the statement and branch coverage for each test.
- Provide the order of tests with the total strategy.
- 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
Step: 1
Control flow graph Start if alength 0 return false if alength 0 while low if b ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started