[FEATURE REQUEST] <title>Add Knapsack Algorithm in Java (Dynamic Programming) [Hactoberfest]
What would you like to Propose?
This issue is created as part of Hacktoberfest 2025. I would like to propose adding the 0/1 Knapsack Algorithm implemented in Java using Dynamic Programming.
This algorithm helps solve optimization problems where we must select items with given weights and values to maximize total value within a limited capacity. It’s one of the most fundamental examples of dynamic programming and is highly useful for learners exploring algorithmic problem-solving in Java.
Issue details
🧮 Algorithm Name
0/1 Knapsack Problem (Dynamic Programming)
📖 Problem Statement
Given n items with certain weights and values, and a knapsack with a weight capacity W, determine the maximum total value that can be achieved without exceeding the capacity.
Each item can either be included or excluded — no fractions allowed (0/1 condition).
💡 Example
Input: values = {60, 100, 120} weights = {10, 20, 30} W = 50
Output: Maximum value = 220
🧰 Language
Java
🔗 Proposed File Path
DynamicProgramming/Knapsack.java
📦 Proposed Implementation
- Use a bottom-up dynamic programming approach.
- Include clear comments and clean variable names.
- Add a
main()method with example input/output for testing.
Additional Information
No response
Can u please assign this to me
i want to work on this issue as a part of hactoberfest 25. can you please assign it to me?
Hi, I'm new to open source and would like to attempt this for Hacktoberfest. Could you please assign it to me?