Maximize total value of items in knapsack with capacity W. Items are either completely included or excluded (0/1 property). Solve using simple recursion.
{
"wt": [
1,
2,
3
],
"val": [
10,
15,
40
],
"W": 6
}65{
"wt": [
1,
3,
4,
5
],
"val": [
1,
4,
5,
7
],
"W": 7
}9{
"wt": [
4,
5,
1
],
"val": [
1,
2,
3
],
"W": 4
}3Sign in to Run Code and Submit