Computer Science, asked by bishtpreeti99, 7 days ago

Solve following 0/1 knapsack problem where n=5, (P1, P2,... , P5) = (16,12,2,5,6), (w1, w2, ...,w5) = (7, 5,3,2, 8) and M = 17.

Answers

Answered by bhakarepranjali
1

Answer:

here this your answer

Explanation:

make a brilliant

Attachments:
Answered by Tulsi4890
0

The 0/1 knapsack problem is a problem in which you are given a set of items, each with a weight and a value, and you are trying to choose a subset of the items that will maximize the value of the items while being under a certain weight limit. In this case, the weight limit is 17.

One way to solve the 0/1 knapsack problem is to use dynamic programming. We can create a table with rows representing the items and columns representing the weight. We can then fill in the table using the following formula:

if j < w[i]:

A[i][j] = A[i-1][j]

else:

A[i][j] = max(A[i-1][j], A[i-1][j-w[i]] + p[i])

where A[i][j] is the maximum value that can be achieved using the first i items with a weight limit of j, p[i] is the value of the i-th item, and w[i] is the weight of the i-th item.

Using this method, we can fill in the entire table and then the maximum value that can be achieved using all of the items with a weight limit of 17 will be in the cell A[5][17].

To learn more about knapsack problem from the given link.

https://brainly.in/question/3775973

#SPJ3

Similar questions