Software Engineering
Consider the following program that uses binary search to check whether the input array contains a specific input value.
INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS
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 {
public boolean contains(int[] a, int b) {
s1 if (a.length == 0) { //b1(true), b2(false) s2
return false;
}
s3 int low = 0;
s4 int high = a.length - 1;
|
s5
s6
|
|
while (low <= high) { //b3(true), b4(false)
int middle = (low + high) / 2;
|
|
s7
|
|
if (b > a[middle]) { //b5(true), b6(false)
|
|
s8
|
|
low = middle + 1;
|
|
s9
|
|
} else if (b < a[middle]) { //b7(true), b8(false)
|
|
s10
|
|
high = middle - 1;
|
|
s11
|
|
} else {
|
|
s12
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
s13
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
- Draw the control-flow graph of the program
- 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:
- t1: a={1,2,3}, b=2
- t2: a={1,2,3}, b=1
iii. t3: a={1,2,3}, b=3
- t4: a={1,2,3}, b=4
Statement coerage matrix
Branch coverage matrix
- Please apply both the total and additional test prioritization (based on statement coverage) on your tests to decide their execution ordering. Please show the priority for each test in each
- Please apply test-suite reduction (based on the branch coverage) on your tests to remove redundant tests. Please show your encoding of the problem in terms integer linear programming (ILP) constraints and objective formulas, and then manually solve the constraints and generate the reduced test
- If s10 is changed during software evolution, mark the dangerous edge in the CFG that you drew in (a) and apply regression test selection (RTS) to select the set of affected
Related Questions
. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java
CS 340 Milestone One Guidelines and Rubric
Overview: For this assignment, you will implement the fundamental operations of create, read, update,
. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class
Retail Transaction Programming Project
Project Requirements:
Develop a program to emulate a purchase transaction at a retail store. This
. The following program contains five errors. Identify the errors and fix them
7COM1028
Secure Systems Programming
Referral Coursework: Secure
. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer
CS 340 Final Project Guidelines and Rubric
Overview The final project will encompass developing a web service using a software stack and impleme