Question: Suppose we have a sequence of n objects a 1 , a 2 , , a n where each a i has size s i
Suppose we have a sequence of n objects a1, a2, , an where each ai has size si . We wish to store these objects in buckets such that the objects in each bucket are consecutive members of the sequence. Assume that we have buckets of k different sizes l1, , lk such that n buckets are available for each size. The cost of any bucket is proportional to its size. The objects aj+1, aj+2, , aj+s fit into a bucket of size lr if and only if X j+s i=j+1 si lr. The problem is to store the objects in buckets with the minimum total cost such that only consecutive objects can be stored in the same bucket. For example, it is not allowed to store objects ai and ai+2 in the same bucket while object ai+1 in a different bucket.
Describe an algorithm that can solve this problem in O(n 2 ) time by formulating the problem as a shortest path problem.
Do present an algorithm that works in O(n k ) time for a constant k > 2.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
