## CSci 3501 Algorithms and Computability - Lab 5.

#### September 24. Due Wednesday, September 30 at 11:59pm

What to submit and when:

• All submissions are electronic: by e-mail to and CC to all lab partners. Please do not delete your e-mail from "Sent mail" or your mailbox until the end of the semester.
• When working on the lab, please comment your work so that it is clear what contributions of each person are.
• At the end of the lab each group should send me the results of their in-class work. Please indicate if this is your final submission.
• If your submission at the end of the lab time was not final, please send me(CC to the lab partner(s)) a final copy before the due time. Please use the subject "3501 Lab N", where N is the lab number.

### Lab assignment

Work in pairs

#### Lab overview and goals

The goal of the lab is to continue a study of approximation and optimal algorithms. Your goal is to solve two cases of a ``shopping cart'' problem:

Suppose you won a grocery shopping spree to fill your cart with items of varying values and sizes. The object is to place the largest value of these items as possible into your cart which has a capacity bound, B. For example, consider B = 40 and the following list of items:

Item     Value (\$)     Size (units)
a 60 10
b 100 20
c 120 30

Which items would you choose?

You need to solve two cases of this problem:

1. Design and implement an efficient algorithm for choosing from n random items of varying sizes and values that fit within the capacity bound B as to maximize value. Items may not be duplicated, other than duplicates within the existing random data set.
2. Design and implement an efficient algorithm for choosing fractional parts of n random items of varying sizes and values that fit within the capacity bound B as to maximize value. Objects in the list may be broken into components of any size before being added to the cart.