Question

2. In the BACKPACK problem, you are given a collection of books of different costs and are tasked with storing as expensive a subset of books as possible so you can sell them at the bookstore in only one trip. Unfortunately, the books are very heavy, and you are limited in how much total weight you can carry. Formally, you are given two arrays C[1.. n] and w[1..n] of positive integers where C[i] is the cost of book i in dollars and w[i] is the weight of book i in pounds. You are also given a positive integer M which is the maximum load you can carry in pounds. Your goal is to compute the maximum total cost of any subset of books you can carry from books 1 through n. (a) For any integers i and m with 0<i< n and 0 < m < M, let MaxCost(i, m) be the maximum cost of any subset of books 1 through i that have a total weight of at most m. Give a recurrence definition for MaxCost(i, m). Dont forget the base cases! (b) Design and analyze a dynamic programming algorithm for solving the BACKPACK problem based on your recurrence from part (a). You should get a running time of O(NM).

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
2. In the BACKPACK problem, you are given a collection of books of different costs and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • (2) Suppose, the game is updated so that every item, i, now has weight, wi], in kilograms (you ca...

    Please help with question 2 (c). (2) Suppose, the game is updated so that every item, i, now has weight, wi], in kilograms (you can assume you are passed the item weights in an array, w, of size m). You can only carry n kilograms of weight. (a) (1 point) Example: Let n Ξ 15, m 5. If the item values are v (5.30, 17, 32, 40) and the item weights are w - 2,4, 3,6,15} which should you choose...

  • Give a decision problem corresponding to each of the search problems given below. (a) • Input:...

    Give a decision problem corresponding to each of the search problems given below. (a) • Input: A set of classes to be scheduled. A list of pairs of the classes which can not be scheduled during the same period. • Output: The largest set of classes that can all be scheduled during the same period. Solution A • Input: A set of classes to be scheduled. A list of pairs of the classes which can not be scheduled during the...

  • A problem that can be solved by the Backtracking technique is the 'Sum-of-Subsets' problem. Given n...

    A problem that can be solved by the Backtracking technique is the 'Sum-of-Subsets' problem. Given n distinct positive numbers (usually called weights), we want to find all possible subsets of these numbers whose sum (or weight) is W. A “binary” state space tree (like in the 0/1 Knapsack problem) can be constructed for this problem, where each level represents one of the n numbers. A left branch indicates that the number is included in the subset, and a right branch...

  • Python Problem, just need some guidance with the description, pseudocode and run time. I believe this...

    Python Problem, just need some guidance with the description, pseudocode and run time. I believe this is an 0-1 knapsack problem? Shopping Spree: (20 points) Acme Super Store is having a contest to give away shopping sprees to lucky families. If a family wins a shopping spree each person in the family can take any items in the store that he or she can carry out, however each person can only take one of each type of item. For example,...

  • Given the sequence an defined recursively as follows: an 3an-1+2 for n 2 1 Al Terms of a Sequence...

    Given the sequence an defined recursively as follows: an 3an-1+2 for n 2 1 Al Terms of a Sequence (5 marks) Calculate ai , аг, аз, а4, а5 Keep your intermediate answers as you will need them in the next question. A2 Iteration (5 marks) Using iteration, solve the recurrence relation when n21 (i.e. find an analytic formula for an). Simplify your answer as much as possible, showing your work and quoting any formula or rule that you use. In...

  • QUESTION 1 (39 MARKS) Suppose you choose 2 books that you are planning to read (the books selected must contain both Malay and English). Thus, there will be a total of 2n number of books, wher...

    QUESTION 1 (39 MARKS) Suppose you choose 2 books that you are planning to read (the books selected must contain both Malay and English). Thus, there will be a total of 2n number of books, where n is the number of team members. Assume that this 2n is the size of population that is approximately normally distributed with mean and standard deviation ơ a) List the number of pages for each of the 2n books as in Table 1. Let...

  • You are considering opening a series of ice cream shops along a long, straight beach. There...

    You are considering opening a series of ice cream shops along a long, straight beach. There are n potential locations where you could open a shop, and the distance of these locations from the start of the beach are, in meters and in increasing order, d1, d2, d3, ...., dn; you may assume all of the di are integers. The constraints are as follows: • At each location you may open at most one ice cream shop. • The expected...

  • Shopping Spree: Acme Super Store is having a contest to give away shopping sprees to lucky...

    Shopping Spree: Acme Super Store is having a contest to give away shopping sprees to lucky families. If a family wins a shopping spree each person in the family can take any items in the store that he or she can carry out, however each person can only take one of each type of item. For example, one family member can take one television, one watch and one toaster, while another family member can take one television, one camera and...

  • Maximum Value But Limited Neighbors You are given an array a[1..n] of positive numbers and an...

    Maximum Value But Limited Neighbors You are given an array a[1..n] of positive numbers and an integer k. You have to produce an array b[1..n], such that: (i) For each j, b[j] is 0 or 1, (ii) Array b has adjacent 1s at most k times, and (iii) sum_{j=1 to n} a[j]*b[j] is maximized. For example, given an array [100, 300, 400, 50] and integer k = 1, the array b can be: [0 1 1 0], which maximizes the...

  • 2. The escape velocity for an object on the surface of the Earth is given by:...

    2. The escape velocity for an object on the surface of the Earth is given by: 2GM = 1.12 x10 m/s VaR A projectile is launched from the surface of the earth at a velocity of v0.5vm. To what height above the Earth's surface does the projectile rise if air resistance is neglected? 3. A blimp is filled with 200m of helium. How much total weight (cargo plus the weight of the blimp itself) can the blimp carry? (b) If...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT