Sie sind auf Seite 1von 2

CMPS 356 Design and Analysis of Algorithms Fall 2011-12

Assignment 2

Due Date: Friday, November 4th Introduction


In this assignment, you will be solving a number of suggested exercises from Chapter 15 of your textbook. Additionally, you will also be solving a 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 to submit the 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 benet-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 specied by pairs of the start times and nish 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.

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 ecient algorithm for determining where Anatjari should rell his bottle in order to make as few stops as possible. Argue why your algorithm is correct.

Question 4 (Goodrich and Tamassia)


Describe an ecient greedy algorithm for making change for a specied 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 , . . . , xn1 } 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 ecient algorithm for nding a placement of guards that uses the minimum number of guards to guard all the paintings with positions in X.

Question 6 (Goodrich and Tamassia)


How can we modify the dynamic programming algorithm from simply computing the best benet value for the 0-1 knapsack problem to computing the assignment that gives this benet?

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.

Das könnte Ihnen auch gefallen