1 / 24

Knapsack Problem Using Dynamic Programming | 0/1 Knapsack Problem | Data Structu

This presentation on knapsack Problem Using Dynamic Programming will acquaint you with a clear understanding of the fractional or 0-1 knapsack problem statement and solution implementation. In this Data Structure Tutorial, you will understand why the difference between 0-1 knapsack and fractional knapsack problems and how you can solve the same problem with less time complexity using DP. Finally, we will cover the dynamic programming implementation of both Knapsack problems. <br>

Simplilearn
Télécharger la présentation

Knapsack Problem Using Dynamic Programming | 0/1 Knapsack Problem | Data Structu

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Agenda

  2. Agenda What is Knapsack Problem

  3. Click here to watch the video

  4. Agenda 0-1 Knapsack Problem

  5. Agenda Implementation

  6. Agenda Fractional Knapsack Problem

  7. Agenda Implementation

  8. What is Knapsack Problem?

  9. What is Knapsack Problem? The knapsack problem is a problem that is used to demonstrate both the problem and the solution. It gets its name from a situation in which the amount of goods that can be carried in a fixed-size knapsack is limited. Given a set of goods with certain weights and values, the goal is to stuff as much value as possible into the knapsack while staying within the weight limit.

  10. 0-1 Knapsack Problem

  11. 0-1 Knapsack Problem 6Kg 10Kg 3Kg 3Kg 2Kg 2Kg 2Kg We will be given weights and values of n items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack.

  12. 0-1 Knapsack Problem 10Kg 3Kg 3Kg 2Kg 6Kg 2Kg 2Kg We are supposed to fill this knapsack, but we can’t break the item.

  13. 0-1 Knapsack Problem 10Kg 3Kg 2Kg 6Kg 2Kg 2Kg 3Kg We must either pick the entire item or not pick at all.

  14. 0-1 Knapsack Problem 10Kg 3Kg 2Kg 6Kg 2Kg 2Kg 3Kg Sometimes it may even lead to a knapsack with some spare space left with it.

  15. Implementation

  16. Fractional Knapsack Problem

  17. Fractional Knapsack Problem 6Kg 10Kg 3Kg 3Kg 2Kg 2Kg 2Kg We will be given weights and values of n items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack.

  18. Fractional Knapsack Problem 10Kg 3Kg 3Kg 2Kg 1Kg 2Kg 6Kg 2Kg 2Kg Unlike 0-1 knapsack problem, we can break items to maximize the total value of knapsack.

  19. Fractional Knapsack Problem 10Kg 3Kg 1Kg 2Kg 2Kg 6Kg 2Kg 2Kg 3Kg Here we will break this 3kg item into a 2kg and 1kg item to completely fill the knapsack

  20. Fractional Knapsack Problem 10Kg 2Kg 1Kg 2Kg 6Kg 2Kg 2Kg 3Kg Here we will break this 3kg item into a 2kg and 1kg item to completely fill the knapsack

  21. Implementation

More Related