Pseudopolynomial Dynamic Programming

Work through the 0–1 subset sum recurrence and see how a loop direction can turn a bounded item into an unlimited one.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Decide reachability for each numeric total
  2. State the encoding assumption

Decide reachability for each numeric total

For nonnegative integer weights and target \(W\), maintain a Boolean array \(D\) on \(0,\ldots,W\), initially true only at zero. An item of weight \(a>0\) yields

\[ D_{\mathrm{new}}[s]=D[s]\lor D[s-a], \]

with a negative index treated as false. The two cases correspond to excluding or including the current item. An in-place update visits \(s\) in descending order so the source \(s-a\) still describes the old prefix. With only the weight \(3\) and target \(6\), an ascending update first sets \(D[3]\), then uses the same item again to set \(D[6]\).

State the encoding assumption

The running time is \(O(nW)\) and space is \(O(W)\). Since the binary representation of \(W\) can be logarithmic in its value, this is pseudopolynomial under bit complexity. Word-parallel subset sum changes the per-item update cost but keeps the dependence on the numeric target. Parameterized complexity formalizes the benefit of limiting a secondary parameter.[1][2]

References

  1. Jeff Erickson, Algorithms ↩
  2. MIT OpenCourseWare, Design and Analysis of Algorithms: Lecture Notes ↩