Skip to content

Instantly share code, notes, and snippets.

@ianbishop
Created March 21, 2011 03:44
Show Gist options
  • Select an option

  • Save ianbishop/878981 to your computer and use it in GitHub Desktop.

Select an option

Save ianbishop/878981 to your computer and use it in GitHub Desktop.
napsack recurrence
if i = 0 or w = 0
m[i, w] = 0
if w[i] > w
m[i - 1, w]
if w[i] <= w
max(m[i - 1, w], m[i - 1, w - w[i]] + v[i])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment