| Download
Project: 11.1 | CS110 | Drummond, MW@17:00 London | Fall 2019 | Rod-cutting with costs | Group 1 | mskgi
Views: 237Kernel: Python 3 (system-wide)
BREAKOUT INSTRUCTIONS
Answer the questions below. You will be asked to present your work after the breakout so make sure to indicate your answers clearly and concisely.
Consider a modification of the rod-cutting problem in which, in addition to a price for each rod, each cut incurs a fixed cost of . The revenue associated with a solution is now the sum of the prices of the pieces minus the costs of making the cuts. (Adapted from Cormen et al. page 370)
Question 1
Paste your dynamic programmic algorithm for the original rod-ccutting problem and make the necessary adjustments for the rod-cutting problem with cost. Use the new set of prices which are as follows:
Length | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
---|---|---|---|---|---|---|---|---|---|---|
Price | 2 | 8 | 8 | 9 | 10 | 17 | 17 | 20 | 24 | 30 |
In [7]:
([0, 2, 6, 8, 12, 14, 18, 20, 24, 26, 30], [0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2])
In [0]:
Question 2
Find the cost for which 2 cuts of 10 is again an optimal solution when the rod is of length 20.
In [0]: