Fast Low-Space Algorithms for Subset Sum

Ce Jin, Nikhil Vyas, Ryan Williams

TL;DR

This paper breaks the "space bottleneck" of the classic Subset Sum problem. The authors present new algorithms that match the $O(nt)$ running time of the standard dynamic programming approach while slashing the space requirement from $O(t)$ down to near-logarithmic $O(\log(nt))$.

What Problem Does This Paper Address?

The Subset Sum problem is a cornerstone of computer science: given a list of $n$ positive integers and a target $t$, can you find a subset of those integers that sums exactly to $t$? While NP-complete in the general sense, it is famously solvable in "pseudopolynomial" time.

Since 1957, the standard solution has been Bellman’s dynamic programming algorithm, which runs in $O(nt)$ time. However, Bellman’s approach requires $O(t)$ space to store its DP table. If your target $t$ is 1 billion, you need gigabytes of memory just to store the table. Previous attempts to reduce this space often resulted in significantly slower running times. This paper asks: Can we achieve the efficiency of Bellman's algorithm without the massive memory overhead?

Methods

The authors move away from traditional DP tables and instead use algebraic and number-theoretic techniques.

  1. Generating Functions: They represent the problem using the polynomial $E(x) = \prod_{i=1}^n (1 + x^{a_i})$. The coefficient of $x^t$ in this polynomial tells us if a subset sum of $t$ exists.
  2. Kane’s Framework: To avoid storing the entire polynomial (which would take $O(t)$ space), they evaluate the polynomial at specific points in a finite field. By using number-theoretic properties (Lemma 1.6), they can detect if the $t$-th coefficient is non-zero by summing these evaluations.
  3. Efficiently Invertible Hash Functions: For their randomized algorithm, they introduce a new type of hash function. This allows them to "color-code" or partition the input integers into smaller groups to keep the math manageable in low space, without actually needing to store the partitions in memory.
  4. Approximate Counting for Determinism: To create a deterministic version, they adapt ideas from Morris’s Algorithm (a classic method for approximate counting in tiny space). They define a novel "polynomial product for approximate counting" to track the number of elements contributing to a sum using only logarithmic bits.

Datasets

As a theoretical computer science paper focused on algorithmic complexity and mathematical proofs, no empirical datasets or benchmarks were used. The results are validated through rigorous complexity analysis.

Key Insights and Ideas

  • The Power of Algebra over DP: The "aha moment" is realizing that checking a coefficient in a polynomial doesn't require building the whole polynomial. By evaluating the expression at various points, you can "probe" the result in a memory-efficient way.
  • Invertibility is Key: To save space, you can't store which numbers went into which hash bucket. The authors solved this by designing hash functions that are "efficiently invertible"—given a bucket ID, you can quickly recreate the list of items that belong there on the fly.
  • Logarithmic Space is Sufficient: The paper proves that the Subset Sum problem, often thought to require linear space relative to the target $t$, can actually be squeezed into space that is only logarithmic in $n$ and $t$.

Key Results

The paper provides a suite of new bounds for Subset Sum (where $n$ is the number of elements and $t$ is the target):

  • Randomized (Log-space): $O(nt)$ time and $O(\log(nt))$ space. This is a massive improvement over the previous best randomized low-space algorithm by Bringmann (SODA 2017), which required $O(n \log t)$ space.
  • Deterministic: $O(n^2 t)$ time and $O(\log t \cdot \log^3 n)$ space. This is the first deterministic algorithm to achieve such low space with a relatively efficient (polynomial in $n$) time complexity.
  • Time-Space Trade-off: For a parameter $k$, they can achieve $O((n+t)k)$ time and $O(t/k)$ space, allowing practitioners to choose a balance based on their available hardware.
  • Weak $\epsilon$-approximation: They provide a poly-logarithmic space algorithm for finding a sum that is "close enough" to the target.

Limitations and Future Work

  • The Deterministic Gap: There is still a gap between the randomized $O(nt)$ time and the deterministic $O(n^2 t)$ time. The authors leave it as an open question whether a deterministic $O(nt)$ log-space algorithm exists.
  • The $O(n+t)$ Frontier: Recent randomized algorithms can solve Subset Sum in $O(n+t)$ time, but they currently require $\Omega(t)$ space. A major open challenge is whether $O(n+t)$ time is possible in $O(\text{polylog}(nt))$ space.
  • Broadening Applications: The authors suggest that their "efficiently invertible hash functions" might be useful for other low-space randomized algorithms beyond Subset Sum.

Summary updated

BibTeX
@inproceedings{jin2021fast,
  author = {Ce Jin and Nikhil Vyas and Ryan Williams},
  title = {{Fast Low-Space Algorithms for Subset Sum}},
  booktitle = {SODA},
  year = {2021},
  doi = {10.1137/1.9781611976465.106},
}
Figure