TheAlgorithms/Go

[ENHANCEMENT] Add 0-1 Knapsack Algorithm

Closed this issue · 3 comments

What would you like to share?

I propose adding the 0-1 Knapsack algorithm to the repository. This dynamic programming algorithm solves the problem of selecting items with given weights and values to maximize total value without exceeding a weight limit.

Problem Statement:
Given a set of items, each with a weight and a value, determine the maximum value that can be obtained without exceeding a specified weight limit. The 0-1 constraint means each item can either be taken or left (no partial inclusion).

Algorithm Description:
The algorithm uses dynamic programming to build a table that tracks the maximum value achievable for every subproblem, based on item count and weight capacity.

Extra issue details

Language: Go
Category: Dynamic Programming

  • Time Complexity: O(n * W) where n is the number of items, and W is the weight capacity of the knapsack.
  • Space Complexity: O(n * W) for the DP table.

Additional information

This algorithm is crucial for teaching dynamic programming concepts, and having it in the repository would benefit many learners.

I would appreciate it if this issue is assigned to me.
With my experience in dynamic programming and Go, I am confident in implementing an efficient solution for the 0-1 Knapsack problem.

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

This issue was closed because it has been stalled for 7 days with no activity.