muhtalhakhan / Hacktoberfest2023

Hacktoberfest 2023 🧑🏻‍💻 OPEN FIRST Pull Request 🎉
https://www.hacktoberfest.com
GNU General Public License v3.0
13 stars 90 forks source link

Create Knapsack.cpp #27

Closed Pranav-Sharma-23 closed 10 months ago

Pranav-Sharma-23 commented 11 months ago

This algorithm works by storing the solutions to the subproblems in a table. The algorithm then iteratively solves the larger problems by using the solutions to the subproblems that have already been solved.

The knapsack problem is a NP-hard problem, meaning that there is no known polynomial-time algorithm for solving it. However, the dynamic programming algorithm shown above is a relatively efficient algorithm for solving the knapsack problem.