why infinity is assigned to other values while in previous knapsack logic we assigned value 0
Doubt in dp array
hello @simi_1188
that is to indicate that solution is not possible (i,e it is false state)
dp[i][v] represents the minimum weight when we have only value v and have considered only first i items.
so while declaring base case-> when we have one item we know we can get only weight w[0] for value val[0]
for any other value we dont have any weight,that why we are assignning a very big value in those states.
but cant we do it by assigning it 0 value like we did in previous knapsack problem
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.