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...
-
What is economic efficiency? Why do economists define efficiency in this way?
-
Find the pH and fraction of dissociation () of a 0.100 M solution of the weak acid HA with Ka = 1.00 10-5.
-
Which interest rate on a bond determines the amount of the semiannual interest payment? a. Market rate b. Effective rate c. Stated rate d. None of the above
-
Hammond Inc. experienced the following transactions for 2012, its first year of operations: 1. Issued common stock for $80,000 cash. 2. Purchased $225,000 of merchandise on account. 3. Sold...
-
Explain the scope of OB in service jobs and describe its role in improving customer service. Creating a high-performance organization is very difficult. Discuss how job satisfaction can impact...
-
Information related to Monty Corp. is presented below. 1. On April 5, purchased merchandise on account from Marigold Company for $39,000, terms 3/10, net/30, FOB shipping point. 2. On April 6, paid...
-
Freddy; a calendar year, cash basis taxpayer; had the following transactions in 2019: He purchased 2,000 shares of General Electric on February 1, 2019. On October 2, 2019, he gave 1,000 shares to...
-
a Two disks with mass 150 g and radius 3 cm are on a frictionless air table. One is stationary and centered at the origin and the other approaches at 12 cm/s for a glancing collision. What is the...
-
adam joins dzd partnership as one of four equal general partners. he makes a cash contribution of 8000 cash as well as property with fair market value of 30000 and 15000 mortgage to be assumed by the...
-
Listed below are some identifying characteristics of organizations. Type a "X " in the appropriate column(s) to indicate which characteristics apply to each type of organization. Some characteristics...
-
Diego Company manufactures one product that is sold for $ 7 5 per unit in two geographic regionsEast and West. The following information pertains to the companys first year of operations in which it...
-
The required production of a product manufactured by Ditto Manufacturers for 2023 is 38 000 units. The opening inventory on 01 January 2023 was 6 000 units and a closing inventory of 4 000 units is...
-
Prepare a classified balance sheet as of December 31 for Crane Distributors. Show the working for the calculation of retained earnings The following financial data for Crane Distributors was...
-
How can you tell from the vertex form y = a(x - h) 2 + k whether a quadratic function has no real zeros?
-
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?
-
Derive Eqs. (E.7) and (E.8) of Example 8.10. Data From Example 8.10:- Equation E.7 and E.8:- Determine the effects of rotary inertia and shear deformation on the natural frequencies of a simply...
-
(a) Derive a general expression for the response of a uniform beam subjected to an arbitrary force. (b) Use the result of part (a) to find the response of a uniform simply supported beam under the...
-
Derive Eqs. (E.5) and (E.6) of Example 8.10. Data From Example 8.10:- Equation E.5 and E.6:- Determine the effects of rotary inertia and shear deformation on the natural frequencies of a simply...
Study smarter with the SolutionInn App