Skip to main content

Posts

Showing posts with the label dp

0-1 knapsack in Dynamic Programming

DP Tutorial 1- 0-1             Knapsack dynamic programming- Problem Explanation - you are given a weight array and respective value array and maximum size of knapsack and you have to put these item in such a way so that you will get maximum total value in knapsack.   Type of knapsack problem 1.Fractional Knapsack- This type of problem lie under the category of greedy .For more details - https://www.geeksforgeeks.org/fractional-knapsack-problem/ 2.0-1 knapsack This is a dp based problem.As 1 means you take this item in knapsack 0 means you didn’t take this item in knapsack. 3.Unbounded knapsack The difference between 0-1 and unbounded knapsack is that you have infinity supply of each item.   How to identify Dynamic Programming- From tutorial 0 we know that you have to find two things 1.Choice- As in   this problem you can take item or not . 2.Optimal- Means maximum or minimum and here...