Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FEATURE REQUEST] <title>Add Knapsack Algorithm in Java (Dynamic Programming) [Hactoberfest] #6777

Open
@Dhanyasri7

Description

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /