Question: White-Box Testing: This is the binary search code int binsearch (int x, int v[], int n){ /* The input array v[] is assumed to be

White-Box Testing:This is the binary search code int binsearch(int x, int v[], int n){ /* The input array v[] is assumed to be sorted in ascending order and n is the array size. You want to find the index of an element x in the array. If x is not found in the array, the routine is supposed to return -1. Answer the questions following the routine. */ a int low, high, mid; b low = 0; c high = n - 1; d while (low <= high) { e mid = (low + high)/2; f if (x < v[mid]) high = mid - 1; g else if (x > v[mid]) low = mid + 1; h else return mid; } i return -1; }

(a) Draw the control flow graph corresponding to the methodbinsearch

(b) Describe the minimum set of test cases (or paths) through the control flow graph that is adequate for statement coverage but not edge/branch coverage. 

(c) What additional test cases (if any) are required for branch coverage?

 

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!