we can easily do it by using sorting and then filling in bag one by one, what is the use of dp here?
0-1 knapsack problem
Hello @sktg99
You cannot do this problem only by sorting and then filling the bag one by one.
Try this on the below test case.
6 5
1 2 3 4 6 weights
5 7 10 13 15 prices
The answer is 13 and NOT 12
im saying sorting by price/weight and how answer is 13 in your test case ?
Hello @sktg99
My above testcase is already sorted on the basis of price/weight in descending order and answer is 13 because we can have only one item of weight 4 price 13