# Final Exam, Fall 2006

### Directions:

• Answer the problems on the exam pages.
• There are eight problems for 120 total points. Actual scale was A=95, C=57.5.
• No books, notes, calculators, or collaboration.
• Time limit was 120 minutes.
• Questions 3, 5 and 7 are "true/false with explanation" -- you get five points for a correct boolean answer, and up to five additional points for a convincing justification.

```  Q1: 15 points
Q2: 15 points
Q3: 10 points
Q4: 20 points
Q5: 10 points
Q6: 20 points
Q7: 10 points
Q8: 20 points
Total: 120 points
```

• Questions 1 and 3 deal with the following scheduling problem. We have n jobs J1,..., Jn, each with a duration di and a reward ri, and a single machine which will be available for some amount of time t. We need to schedule the jobs in some order without knowing t, in order to maximize the amount of total reward from the jobs we complete. If our time runs out while we are running a job Ji, we get a proportional partial reward for the time x we spent on it -- this partial reward is xri/di.

• Questions 4, 6, and 8 deal with variants of the BIN-PACKING problem. It may be helpful for you to have the definition of the original BIN-PACKING problem: The input is a set of n items, each with a positive size, and a positive bin size b. The output of the optimization version of the problem is the minimum number of size-b bins needed to store the n items. The decision version of the problem takes an additional positive integer k as input, and the output is a boolean telling whether the items can be packed into k bins of size b. You may assume that this decision problem is NP-complete.

• Question 1 (15):

Give an algorithm, with running time polynomial in n, that determines an order of the jobs that will achieve the optimal reward for all values of t. (You do not need to prove here that your order has this property, that is Question 2.) State and justify a polynomial bound on the running time.

• Question 2 (15):

Prove that no other order on the jobs can achieve a greater value than your order from Question 1, for any possible value of t. (Hint: You can show that any other order either achieves the same value as yours does, or can be altered to get a greater value for some t.)

• Question 3 (10):

True or false with justification: Let A be an algorithm that operates on a list of size n as follows. If n ≤ 1, then A takes only O(1) time. Otherwise A spends O(n) time to split the list into two pieces, each of which has size at most 2n/3. It then calls itself recursively on the two pieces. Then any such A has a running time that is polynomial in n.

• Question 4 (20):

Consider the special case of the BIN-PACKING problem where the size of each item is a positive integer and the bin size is a constant positive integer, called b. Given n items, we need to find the exact minimum number of bins needed to store them all. (The problem is no longer NP-complete in this special case, unless P = NP.) Describe an algorithm to solve this problem that has a running time that is polynomial in b if b is considered to be a constant. State and justify a polynomial bound on your running time.

• Question 5 (10):

True or false with justification: The SQUARE-TILING problem has as input a set of n2 tiles, each of which has one of n2 possible colors. (It is possible that not all the colors are used.) The output is a boolean saying whether the tiles can be put in an n by n square such that each tile is used exacctly once and such that no color appears more than once in any row or in any column. Then there is a polynomial-time reduction from SQUARE-TILING to HAMILTON-CIRCUIT.

• Question 6 (20):

The RECTANGLE problem is the following variation of BIN-PACKING. We are given a set of n jobs, each with a positive integer size. Let S be the sum of the n sizes. The problem is to determine whether there exist integers b and k such that b > 1, k > 1, bk = S, and the items can be divided into k sets each of which has total size b. (The name RECTANGLE comes from thinking of each job of size si as a 1 by si rectangle, and asking whether these rectangles can be packed into any single rectangle without wasted space, other than the trivial 1 by S solution.) Prove that the RECTANGLE problem is NP-complete.

• Question 7 (10):

True or false with justification: Let R be a resource to which I want access, and suppose that in any round of a protocol I have at least a 1/n chance of getting R. Further suppose that the events of success in each round are independent. Then my chance of succeeding at least once in the first n rounds is at least 1/2.

• Question 8 (20):

Now consider the variant of BIN-PACKING where the bin size is b (not necessarily an integer) and each item has size less than b/3. This version is still NP-complete, though we won't prove this here. Your problem is to give an algorithm that approximates the optimal packing into bins, and prove a bound on the quality of your approximation. In particular, prove that if your algorithm uses 3a+1 bins for some integer a, then the optimal algorithm uses at least 2a+1 bins.