Answered step by step
Verified Expert Solution
Link Copied!

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



  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

Step: 1

Control flow graph Start if alength 0 return false if alength 0 while low if b ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Discrete and Combinatorial Mathematics An Applied Introduction

Authors: Ralph P. Grimaldi

5th edition

201726343, 978-0201726343

More Books

Students also viewed these Programming questions