There are n different sizes of boxes, from 1 to n. There is an
unlimited supply of boxes of each size t, each with a value
vt .
A box of size t can hold several smaller boxes of sizes
a1, a2, . . . , ak as long as the
sum of sizes a1 + a2 + . . . + ak
is strictly less than t.
Each of these boxes may be filled with yet more boxes, and so
on.
Design an algorithm which runs in O(n 2 )
time and finds the maximum value that can be attained by taking one
box, potentially with smaller boxes nested inside it.
Clarifications:
• What input is given in an instance of the problem? The integer
n, and n integers v1, . . . , vn.
• What are the sizes of the boxes? The sizes are 1, 2, . . . ,
n.
• Are there any constraints on the values of the boxes? You can
assume that all vt are positive.
Hint: To fill the interior of a box of size t, you either use
only one box (in which case the optimal packing is straightforward)
or you use two or more smaller boxes.
Do not write the code, give steps and methods. Explain
the steps of algorithm, and the logic behind these steps in plain
English and give Diagrams and time complexity
There are n different sizes of boxes, from 1 to n. There is an unlimited supply of boxes of each size t, each with a val
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am