Approximately Counting Knapsack Solutions in Subquadratic Time

Published: 01 Jan 2025, Last Modified: 17 May 2025SODA 2025EveryoneRevisionsBibTeXCC BY-SA 4.0
Abstract: We revisit the classic #Knapsack problem, which asks to count the Boolean points (x1, x2, …, xn ) ∈ {0,1}n in a given half-space . This #P-complete problem is known to admit (1 ± ∊)-approximation. Before this work, [Dyer, STOC 2003]’s Õ (n2 5 + n2∊-2)-time randomized approximation scheme remains the fastest known in the natural regime of ε ≥ 1/ poly log n.In this paper, we give a randomized (1 ± ε )-approximation algorithm for #Knapsack in Õ ( n1.5 ε -2) time (in the standard word-RAM model), achieving the first sub-quadratic dependence on n. Such sub-quadratic running time is rare in the approximate counting literature in general, as a large class of algorithms naturally faces a quadratic-time barrier.Our algorithm follows Dyer’s framework, which reduces #Knapsack to the task of sampling (and approximately counting) solutions in a randomly rounded instance with poly(n )-bounded integer weights. We refine Dyer’s framework using the following ideas:• We decrease the sample complexity of Dyer’s Monte Carlo method, by proving some structural lemmas for “typical” points near the input hyperplane via hitting-set arguments, and appropriately setting the rounding scale.• Instead of running a vanilla dynamic program on the rounded instance, we employ techniques from the growing field of pseudopolynomial-time Subset Sum algorithms, such as FFT, divide-and-conquer, and balls-into-bins hashing of [Bringmann, SODA 2017].To implement these ideas, we also need other technical ingredients, including a surprising application of the recent Bounded Monotone (max, +)-Convolution algorithm by [Chi, Duan, Xie, and Zhang, STOC 2022] (adapted by [Bringmann, Dürr, and Polak, ESA 2024]), the notion of sum-approximation from [Gawrychowski, Markin, and Weimann, ICALP 2018]’s #Knapsack approximation scheme, and a two-phase extension of Dyer’s framework for handling tiny weights.*This work was done in part while two authors were visiting the Simons Institute for the Theory of Computing.
Loading