5 Unsolved Problems on Design and Computer Algorithms | CMSC 451, Assignments of Computer Science

Material Type: Assignment; Class: DSG&AN CMPTR ALGOR; Subject: Computer Science; University: University of Maryland; Term: Unknown 2006;

Typology: Assignments

Pre 2010

Uploaded on 02/13/2009

koofers-user-83q
koofers-user-83q 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CMSC 451
Summer 2006 Homework 4 Juli´an Mestre
Due on Wednesday 16
Problem 1: We are going on a trip along the Appalachian trail. We have a list of all possible
campsites that we can camp in along the way (say n). We want to do this trip in exactly kdays,
stopping k1 nights to camp. Our goal is to plan this trip so that we minimize the maximum
amount of walking done in a single day. In other words, if our trip involves 3 days of walking, and
we walk 11, 14, 12 miles on each day respectively, the cost is 14. Another schedule that involves
walking 11, 13, 13 miles on each day has cost 13. The locations of the campsites are specified
in advance, and we can only camp at a campsite. Your algorithm should be based on dynamic
programming and run efficiently.
Problem 2: You are hired by a financial company, Crazy Buck Ltd., to design a program to find
good investments. The company has done a lot of research in ndifferent emerging markets. For
market ithey have a set of investment strategies Si,1, Si,2,...,Si,k. Strategy Si,j involves investing
Ii,j dollars and, according to their research, has a return of Ri,j . Assume all numbers are integers.
The company has a budget Bon how much it can invest. Because two strategies for the same
market typically overlap, you can choose at most one strategy per market. The goal is to maximize
profit. Show your boss at Crazy Buck how to solve her problem using dynamic programming!
Problem 3: In the knapsack problem we are given a set of GREEDY-KNAPSACK
sort items
Let Sbe empty
For each item i[in order]
If w(S) + wiW
add ito S
return S
nitems to fit in a knapsack of size W. Item ihas weight wi
and value vi. We are to find a set S {1,...,n}such that
PiSwiW, which maximizes PiSvi.
In class we saw a solution for this problem using dynamic
programming, here we explore the possibility of using the
greedy algorithm on the right. A few natural ways of sort-
ing the items would be in increasing wi, decreasing vi, and
decreasing vi
wi. Show that these strategies may fail to find an
optimal solution.
Problem 4: From the book: Exercise 6.6.
Problem 5: From the book: Exercise 6.13.
Problem (extra credit): Give an O(n2) time algorithm for problem 1.

Partial preview of the text

Download 5 Unsolved Problems on Design and Computer Algorithms | CMSC 451 and more Assignments Computer Science in PDF only on Docsity!

CMSC 451

Summer 2006 Homework 4^

Juli´an Mestre

Due on Wednesday 16

Problem 1: We are going on a trip along the Appalachian trail. We have a list of all possible campsites that we can camp in along the way (say n). We want to do this trip in exactly k days, stopping k − 1 nights to camp. Our goal is to plan this trip so that we minimize the maximum amount of walking done in a single day. In other words, if our trip involves 3 days of walking, and we walk 11, 14, 12 miles on each day respectively, the cost is 14. Another schedule that involves walking 11, 13, 13 miles on each day has cost 13. The locations of the campsites are specified in advance, and we can only camp at a campsite. Your algorithm should be based on dynamic programming and run efficiently.

Problem 2: You are hired by a financial company, Crazy Buck Ltd., to design a program to find good investments. The company has done a lot of research in n different emerging markets. For market i they have a set of investment strategies Si, 1 , Si, 2 ,... , Si,k. Strategy Si,j involves investing Ii,j dollars and, according to their research, has a return of Ri,j. Assume all numbers are integers. The company has a budget B on how much it can invest. Because two strategies for the same market typically overlap, you can choose at most one strategy per market. The goal is to maximize profit. Show your boss at Crazy Buck how to solve her problem using dynamic programming!

Problem 3: In the knapsack problem we are given a set of GREEDY-KNAPSACK

sort items Let S be empty For each item i [in order] If w(S) + wi ≤ W add i to S return S

n items to fit in a knapsack of size W. Item i has weight wi and value∑ vi. We are to find a set S ⊆ { 1 ,... , n} such that

i∈S wi^ ≤^ W^ , which maximizes^

i∈S vi. In class we saw a solution for this problem using dynamic programming, here we explore the possibility of using the greedy algorithm on the right. A few natural ways of sort- ing the items would be in increasing wi, decreasing vi, and decreasing (^) wvii. Show that these strategies may fail to find an optimal solution.

Problem 4: From the book: Exercise 6.6.

Problem 5: From the book: Exercise 6.13.

Problem (extra credit): Give an O(n^2 ) time algorithm for problem 1.