CMPS 356 Design and Analysis of Algorithms Fall 2011-12 Assignment 2
Due Date: Friday, riday, November November 4th Introduction In this assignment, you will be solving a number of suggested exercises from Chapter Chapter 15 of your textbook. Additionally Additionally,, you will also be solving solving a number number of suggested exercises from Chapter 4 of the following textbook: Algorithm Design: Foundations, Analysis, and Internet Applications , by Michael T. Goodrich and Roberto Tamassia. Course Website: http://ww3.algorithmdesign.net/ More exercises can be found in the problem database associated with your textbook. Note that you need need to submit the solutions solutions to questions 3, 5, and 7 only. The remaining execises should be solved but not submitted.
What to submit • Submission is via MOODLE. The solutions to the textbook exercises, produced using LATEX. • You are allowed to work on this assignment in groups, provided there are no more than two students per group.
Question 1 (Goodrich and Tamassia) Let S = {a , b , c , d , e , f , g} be a collection of objects with benefit-weight values as follows: a : (12, 4), b : (10, 6), c : (8, 5), d : (11, 7), e : (14, 3), f : (7, 1), g : (9, 6). What is an optimal solution to the fractional knapsack problem for S assuming we have a sack that can hold objects with total weight 18? Show your work.
Question 2 (Goodrich and Tamassia) Suppose we are given a set of tasks specified by pairs of the start times and finish times as T = {(1, 2), (1, 3), (1, 4), (2, 5), (3, 7), (4, 9), (5, 6), (6, 8), (7, 9)}. Solve the task scheduling problem for this set of tasks.
1
Question 3 (Goodrich and Tamassia) A native Australian named Anatjari wishes to cross a desert carrying only a single water bottle. He has a map that marks all the watering holes along the way. Assuming he can walk k miles on one bottle of water, design an efficient algorithm for determining where Anatjari should refill his bottle in order to make as few stops as possible. Argue why your algorithm is correct.
Question 4 (Goodrich and Tamassia) Describe an efficient greedy algorithm for making change for a specified value using a minimum number of coins, assuming there are four denominations of coins (called quarters, dimes, nickels, and pennies), with values 25, 10, 5, and 1, respectively. Argue why your algorithm is correct.
Question 5 (Goodrich and Tamassia) In the art gallery guarding problem, we are given a line L that represents a long hallway in an art gallery. We are also given a set X = {x0 , x1 , . . . , x −1 } of real numbers that specify the positions of paintings in this hallway. Suppose that a single guard can protect all the paintings within distance at most 1 of his or her position (on both sides). Design an efficient algorithm for finding a placement of guards that uses the minimum number of guards to guard all the paintings with positions in X . n
Question 6 (Goodrich and Tamassia) How can we modify the dynamic programming algorithm from simply computing the best benefit value for the 0-1 knapsack problem to computing the assignment that gives this benefit?
Question 7 (CLRS) Read Section of Chapter 15 in your textbook. Solve exercises 15.1-2, 15.1-3, and 15.1-4.
Question 8 (CLRS) Solve Problem 15-4 of your textbook.
2