数据库代写 | CS 5800 – Assignment #5

本次作业代写是关于java 数据库和单元测试相关的一个Assignment

Note 1: Your submission header must have the format as shown in the above-enclosed rounded rectangle.

Note 2: Homework is to be done individually. You may discuss the homework problems with your fellow students, but you are NOT allowed to copy – either in part or in whole – anyone else’s answers.

Note 3: All submitted materials must be legible. Figures/diagrams must follow the given instructions.

Note 4: Your deliverable should be a .pdf file submitted through Gradescope until the deadline. Do not forget to assign a page to each of your answers when making a submission.

Note 5: Please use and check the Canvas discussion for further instructions, questions, answers, and hints.

1. [20 points] Provide the following requested hibernate implementations (submit your solution to an online repository) to create/delete instances of:

a. [10 points] Customer, Professor, MainCreate, and MainDelete (Java application). If a customer is included, so is the corresponding professor. The same behavior for deletion. IDs are generated automatically.

 

2. [20 points] Considering the binary search algorithm provided below to answer the following questions.

1 public static int binarySearch(int[] array, int searchValue) {

2 int first; int last; int middle; int position;

3 boolean found; // Flag

4 first = 0; last = array.length – 1; position = -1; found = false;

5 while (!found && first <= last) {

6 middle = (first + last) / 2;

7 if (array[middle] == searchValue)

8 {found = true; position = middle;} 9 else if (array[middle] > searchValue)

10 last = middle – 1;

11 else

12 first = middle + 1;

13 }

14 return position;

15 }

a) [5 points] Find a test case that could be used to perform all-nodes coverage test. Your test case should be formed by an array and a search value, e.g., array = {1,2,3}, searchValue = 2.

b) [5 points] Show the sequence of executed statements that you performed to find the answer of part

a). Example of a hypothetical sequence of executed statements: 1-2-3-4-2-3-5-6-7-14.

c) [5 points] Draw the control graph of this algorithm.

d) [5 points] Calculate the cyclomatic complexity metric (maximal linearly independent set of paths though a graph) and show a possible set of linearly independent paths for this graph.