TheAlgorithms / Go

Algorithms and Data Structures implemented in Go for beginners, following best practices.
https://the-algorithms.com/language/go
MIT License
16.08k stars 2.6k forks source link

[ENHANCEMENT] Add 0-1 Knapsack Algorithm #748

Open Anikettt01 opened 2 days ago

Anikettt01 commented 2 days ago

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

Additional information

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

Anikettt01 commented 2 days ago

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.