Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16.2-2 #477

Open
ustcjsj opened this issue Apr 27, 2023 · 2 comments
Open

16.2-2 #477

ustcjsj opened this issue Apr 27, 2023 · 2 comments

Comments

@ustcjsj
Copy link

ustcjsj commented Apr 27, 2023

0-1-KNAPSACK(n, W)
Initialize an (n + 1) by (W + 1) table K
for i = 0 to n
K[i, 0] = 0
for j = 0 to W
K[0, j] = 0
for i = 1 to n
for j = 1 to W
if j < i.weight
K[i, j] = K[i - 1, j]
else
K[i, j] = max(K[i - 1, j], K[i - 1, j - i.weight] + i.value)

@ustcjsj
Copy link
Author

ustcjsj commented Apr 27, 2023

the initialization part
you have to initialize it from 0

@walkccc
Copy link
Owner

walkccc commented May 7, 2023

Hi @ustcjsj,

Can you create a PR for this. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants