1. Apply the dynamic programming algorithm discussed in class to solve the knapsack problem. (10 points)...
3. Apply the dynamic programming algorithm discussed in class to solve the knapsack problem. (20 points) a. Show the completed table. b. Which items are included in the final configuration of the knapsack? c. What is the maximum value that can fit in the knapsack using a configuration of these items? Item 1 weighs 2 pounds and is worth $9.00 Item 2 weighs 3 pounds and is worth $12.00 Item 3 weighs 5 pounds and is worth $14.00 Item 4...
a) Implement the bottom-up dynamic programming algorithm for the
knapsack problem in python. The
program should read inputs from a file called “data.txt”, and the
output will be written to screen,
indicating the optimal subset(s).
b) For the bottom-up dynamic programming algorithm, prove that its
time efficiency is in
Θ(nW), its space efficiency is in Θ(nW) and the time needed to find
the composition of an
optimal subset from a filled dynamic programming table is in
O(n).
Consider the following...
Apply the top-down (i.e., memory function) dynamic programming
algorithm to the following instance of the knapsack problem. Input
your results in the table shown below. For empty cells, input a
single minus sign (-) into the cell.
Warning: When filling in the table below with your
answers, be sure to type the number in each cell, with no decimal
points or leading zeros or spaces. For example, if a cell should
contain a value of 0, just type "0" and...
Recall that in the "Knapsack Problem", there are n items having respective values V1..n) and weights W1..n), all greater than 0 and one needs to maximize the total value of the subset of the items placed in the knapsack limited by a weight capacity of W In the 0-1 Knapsack Problem, each item must be either be included or excluded in its entirety, in light of the fact that this problem is to be "NP-Complete", how can one solve the...
Algorithm and computing system(Python) What is dynamic programming? Why does it usually work faster? Using the dynamic programming solution for the knapsack problem, compute a solution to this knapsack problem: Weight value 2 16 3 19 4 23 5 28 total number of items = 4 capacity of the knapsack = 7 Suppose that the similarity between an object O and 6 other objects in the database A,B,C,D,E and F are as follows: sim(A,O) = 0.1 sim(B,O) = 0.3 sim(C,O)...
Haloo , i have java program , Java Program , dynamic program Given a knapsack with capacity B∈N and -n- objects with profits p0, ..., p n-1 and weights w0, ..., wn-1. It is also necessary to find a subset I ⊆ {0, ..., n-1} such that the profit of the selected objects is maximized without exceeding the capacity. However, we have another limitation: the number of objects must not exceed a given k ∈ N Example: For the items...
Write an algorithm that uses dynamic program to find a solution to the knapsack problem. The input is the capacity of the knapsack then each row of the table of values and weights. The output is the resulting maximum value of the items that can be put in the knapsack. Code submitted in C++ Sample Input 1: 11 1 1 6 2 18 5 22 6 28 7 Sample Output 1: 40 Sample Input 2: 8 15 1 10 5...
Solve the 0-1 knapsack problem given the following items, each labeled with weight and value. Assume the total weight limit W is 8 lbs. Item 1 Value ($) 8 Weight (lb) 1 23 4 40 30 54 2 6 3
Consider the following more general version of the Knapsack problem. There are p groups of objects O1, O2, . . . , Op and a knapsack capacity W. Each object x has a weight wx and a value vx. Our goal is to select a subset of objects such that: • the total weights of selected objects is at most W, • at most one object is selected from any group, and • the total value of the selected objects...
I'm having trouble with my Java Homework in which my professor wants us to solve the 0-1 Knapsack problem with Dynamic Programming. The code below is what she provided and she requested that we not change any of her existing code but simply add to it. As you can see she gave us the stub file for the knapsack class and the Item class. You are a thief with a knapsack with a carrying capacity of knapsackCapacity pounds. You want...