Classical and quantum dynamic programming for Subset-Sum and variants

Jonathan Allcock, Yassine Hamoudi, Antoine Joux, Felix Klingelhöfer, Miklos Santha · DOI

Abstract

Subset-Sum is an NP-complete problem where one must decide if a multiset of $n$ integers contains a subset whose elements sum to a target value $m$. The best-known classical and quantum algorithms run in time $\tilde{O}(2^{n/2})$ and $\tilde{O}(2^{n/3})$, respectively, based on the well-known meet-in-the-middle technique. Here we introduce a novel classical dynamic-programming-based data structure with applications to Subset-Sum and a number of variants, including Equal-Sums (where one seeks two disjoint subsets with the same sum), 2-Subset-Sum (a relaxed version of Subset-Sum where each item in the input set can be used twice in the summation), and Shifted-Sums, a generalization of both of these variants, where one seeks two disjoint subsets whose sums differ by some specified value. Given any modulus $p$, our data structure can be constructed in time $O(n^2p)$, after which queries can be made in time $O(n^2)$ to the lists of subsets summing to any value modulo $p$. We use this data structure in combination with variable-time amplitude amplification and a new quantum pair finding algorithm, extending the quantum claw finding algorithm to the multiple solutions case, to give an $O(2^{0.504n})$ quantum algorithm for Shifted-Sums, an improvement on the best-known $O(2^{0.773n})$ classical running time. Incidentally, we obtain new $\tilde{O}(2^{n/2})$ and $\tilde{O}(2^{n/3})$ classical and quantum algorithms for Subset-Sum, not based on the seminal meet-in-the-middle method. We also study Pigeonhole Equal-Sums and Pigeonhole Modular Equal-Sums, where the existence of a solution is guaranteed by the pigeonhole principle. For the former problem, we give faster classical and quantum algorithms with running time $\tilde{O}(2^{n/2})$ and $\tilde{O}(2^{2n/5})$, respectively. For the more general modular problem, we give a classical algorithm that also runs in time $\tilde{O}(2^{n/2})$.

Introduction

The Subset-Sum problem is a cornerstone of computational complexity. While traditionally approached via "meet-in-the-middle" strategies, these methods have reached a performance plateau. This paper introduces a paradigm shift by leveraging dynamic programming (DP) to facilitate the "representation technique," a method that decomposes solutions into searchable pairs. We extend these techniques to several variants, most notably Shifted-Sums, which generalizes both Subset-Sum and Equal-Sums by seeking two disjoint subsets whose sums differ by a target value $s$.

Methodology: The DP-Based Subset Oracle

The core innovation is a novel DP-based data structure. By constructing a table of cardinalities $t_p[i, j]$ (the number of subsets of the first $i$ elements summing to $j \pmod p$), the authors create a searchable index. Unlike traditional DP, which simply counts or finds a single solution, this structure allows for the retrieval of the $I$-th subset in a specific "sum bin" in $O(n^2)$ time. This effectively turns the DP table into a virtual, indexed list of all possible subsets summing to a specific value modulo $p$.

Advancing the Representation Technique

The representation technique relies on the fact that a single solution can often be represented as the sum of many different pairs of subsets. Previous analyses often focused on the minimum size of a solution. This work shifts the focus to the maximum solution ratio $\ell$, demonstrating that larger solutions offer more representations that can be exploited for algorithmic speedups.

Complexity analysis of the representation technique

By moving the representation technique from a heuristic used in cryptography for average-case inputs to a provable tool for worst-case scenarios, the authors achieve significant performance gains. This is particularly evident in the quantum domain, where variable-time amplitude amplification is used to manage the varying sizes of subset "bins."

Key Results and Complexity Bounds

The primary achievement of this research is a new quantum algorithm for Shifted-Sums running in $O(2^{0.504n})$, a substantial improvement over the previous classical best of $O(2^{0.773n})$. Additionally, the paper provides improved bounds for "Pigeonhole" variants, where solutions are guaranteed to exist.

Comparison of algorithmic complexity bounds

As shown in the table above, the researchers also derived new $\tilde{O}(2^{n/2})$ classical and $\tilde{O}(2^{n/3})$ quantum algorithms for the standard Subset-Sum problem that do not rely on the traditional meet-in-the-middle approach.

Conclusion and Future Work

While this work sets new benchmarks, several open questions remain. A notable gap exists in the quantum speedup for Pigeonhole Modular Equal-Sums, where a bottleneck in transitioning between DP table types prevented an improvement over the classical $O(2^{n/2})$ bound. Future research may focus on overcoming these modular bottlenecks or exploring whether the Strong Exponential Time Hypothesis (SETH) implies that these new bounds are near the theoretical limits of efficiency.

Summary updated

BibTeX
@inproceedings{allcock2022classical,
  author = {Jonathan Allcock and Yassine Hamoudi and Antoine Joux and Felix Klingelhöfer and Miklos Santha},
  title = {{Classical and quantum dynamic programming for Subset-Sum and variants}},
  booktitle = {ESA},
  year = {2022},
  url = {https://openreview.net/forum?id=YKJ8uzXqb7},
}
Figure