3. Dynamic programming. Consider the 0-1 knapsack problem. You have a knapsack with total capacity W,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
3. Dynamic programming. Consider the 0-1 knapsack problem. You have a knapsack with total capacity W, and n distinct items with values V₁, V2, ..., Un and weights w₁, W2, ..., Wn. You can either choose to add one item to your knapsack or leave it. The goal is to maximize the value of the items in the knapsack without exceeding its capacity. Answer the questions below. (a) Prove that it has optimal substructure (hint: consider the solutions to all sub-problems in which item i, with weight w, has been removed). (b) Based on the optimal substructure, give a recursion to solve the problem. (c) Show an example of the optimal substructure given the input below for W = 10 (clearly indicate the solution to the overall problem and the solutions to sub-problems) i 1 2 3 4 Wi Vi 6 30 3 14 4 16 2 9 (d) Show the overlapping sub-problems as you recursively solve the problem for the input above (i.e., draw the recursion tree in which each node corresponds to the size of the knapsack for the corresponding sub-problem). Give an algorithm to solve the problem (write pseudo-code). (f) Solve the problem instance above using your algorithm (show the completed dynamic program- ming table).. (g) Give the running time of your algorithm. 3. Dynamic programming. Consider the 0-1 knapsack problem. You have a knapsack with total capacity W, and n distinct items with values V₁, V2, ..., Un and weights w₁, W2, ..., Wn. You can either choose to add one item to your knapsack or leave it. The goal is to maximize the value of the items in the knapsack without exceeding its capacity. Answer the questions below. (a) Prove that it has optimal substructure (hint: consider the solutions to all sub-problems in which item i, with weight w, has been removed). (b) Based on the optimal substructure, give a recursion to solve the problem. (c) Show an example of the optimal substructure given the input below for W = 10 (clearly indicate the solution to the overall problem and the solutions to sub-problems) i 1 2 3 4 Wi Vi 6 30 3 14 4 16 2 9 (d) Show the overlapping sub-problems as you recursively solve the problem for the input above (i.e., draw the recursion tree in which each node corresponds to the size of the knapsack for the corresponding sub-problem). Give an algorithm to solve the problem (write pseudo-code). (f) Solve the problem instance above using your algorithm (show the completed dynamic program- ming table).. (g) Give the running time of your algorithm.
Expert Answer:
Answer rating: 100% (QA)
a The 01 knapsack problem exhibits optimal substructure which mea... View the full answer
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date:
Students also viewed these programming questions
-
A Van de Graaff generator has a 0 . 1 1 mC charge on its conducting spherical terminal. At this distance, what is the magnitude of the force that the field exerts on a 1 . 9 5 \ mu C point charge on...
-
The Modigliani-Miller theorem suggests that the capital structure of a company does not affect its market value in a perfect capital market. However, in reality, firms often make decisions about debt...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
The Chief Financial Officer at Ford Motor Company is said to usea hybrid-costing system. Define the hybrid-costing system. Explainthe advantages to this company to use this system. I want a 10 page 2...
-
The size of the U.S. civilian workforce for the years from 1950 and projected to 2050 can be approximated by a linear equation determined by the line connecting the points (1950, 62.2) and (2050,...
-
Refer to the Jones Oil and Lube data in S6-6. Use the high- low method to determine the variable and fixed cost components of Jones Oil and Lubes operating costs. Use this information to project the...
-
Which of the following control procedures would most likely prevent or detect purchases from unauthorized vendors? a. Maintain updated guidelines for purchase transactions. b. Establish procedures...
-
Yost-Perry Industries (YPI) senior management team wants to improve the profitability of the firm by accepting the right set of orders. Currently, decisions are made using the traditional method,...
-
Evaluate the following definite integral. 1 x (4x 1)4 dz 0 1/3 X
-
TourneSol Canada, Ltd. is a producer of high quality sunflower oil. The company buys raw sunflower seeds directly from large agricultural companies, and refines the seeds into sunflower oil that it...
-
From the following particulars of Rose Mary Company, calculate the total direct labor variance. Total Direct Materials Variance (b) Direct Materials Cost Variance $300 F Direct Materials Efficiency...
-
List the major disadvantages of starting up a business from scratch.
-
List at least five possible ways that you may do to improve the possibilities of success in a small business.
-
What is meant by critical risks in a business plan?
-
What is meant by the final steps in regard to buying a business?
-
What is the milestone chart? Is it necessary to be included in a business plan?
-
Sony PS5 Pricing Sony has released its latest game console, Playstation 5 (PS5). The price is set to be $400 per console. It is rumored that Sony incurs a marginal cost of $450 to produce a PS5,...
-
In Problem use absolute value on a graphing calculator to find the area between the curve and the x axis over the given interval. Find answers to two decimal places. y = x 3 ln x; 0.1 x 3.1
-
Suppose we have a reference to a node in a singly linked list that is guaranteed not to be the last node in the list. We do not have references to any other nodes (except by following links)....
-
Write the remaining procedures to implement AVL single and double rotations.
-
Give an efficient algorithm to determine if there exists an integer i such that Ai = I in an array of integers A1 < A2 < A3 < < AN. What is the running time of your algorithm?
-
In May 2023 Bernard, a self-employed plumber, and his son Gerald, a self-employed electrician, purchased 1,000 empty barrels from a Scottish whisky distillery. The barrels were over 100 years old and...
-
Three brothers, Daniel, David and Derrick have been discussing their respective taxation affairs and how much they dislike paying tax. None of them are Scottish taxpayers. Daniel's income for tax...
-
On 6 August 2023, Danh (who is not a Scottish taxpayer) commenced self-employment as a sole trader. In addition, on 6 September 2023, he joined an existing partnership run by Ebele and Fai. The...
Study smarter with the SolutionInn App