Python Knapsack Problem: imagine you are carrying a knapsack with capacity to hold a total of weight C. You are selecting among n items with values A={a_1, a_2, ... , a_n} and associated weights W={w_1, w_2, ... , w_n}. Here the weights and values are all positive. You wish to maximize the total value of the items you select not exceeding the given weight capacity, example, maximize sum_{a in A} such that sum_{w in W} <= C.  Note that you can only select your items once.  Reformulate

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 9PP: (Data processing) Your professor has asked you to write a C++ program that determines grades at the...
icon
Related questions
Question

 

Python Knapsack Problem: imagine you are carrying a knapsack with capacity to hold a total of weight C. You are selecting among n items with values A={a_1, a_2, ... , a_n} and associated weights W={w_1, w_2, ... , w_n}. Here the weights and values are all positive. You wish to maximize the total value of the items you select not exceeding the given weight capacity, example, maximize sum_{a in A} such that sum_{w in W} <= C.  Note that you can only select your items once.

  1.  Reformulate this as a bottom-up dynamic programming problem as follows. Define K_{i,j} as the highest possible value sum considering items 1 through i and total weight capacity j (j <= C). What is the base case i.e. K_{0,j} for all j and K_{i,0} for all i. What is the loop statement?

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Problems on Dynamic Programming
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole