arXiv:2608.22355cs.DSAug 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2608.22355

Recovery Beats Storage: Improved Space for Preprocessed 3SUM

Amir Carmel, Yakov Kosoburd, Robert Krauthgamer

Abstract

The 3SUM problem asks, given sets A,B,CA, B, C of integers, whether there exist a∈Aa \in A and b∈Bb \in B whose sum belongs to CC. In the preprocessed variant with unknown CC, one preprocesses sets AA and BB, each of size nn, and subsequently answers a query specified by subsets A′⊆AA' \subseteq A, B′⊆BB' \subseteq B and a target set C′C' of size O(n)O(n), by solving the 3SUM instance (A′,B′,C′)(A', B', C').

Kirkpatrick, Kuszmaul, Mathialagan, and Vassilevska Williams [ICALP 2026] gave the first algorithm with subquadratic space for this problem, achieving O~(n3/2+ϵ)\tilde{O}(n^{3/2+\epsilon}) query time using O~(n2−2ϵ/3)\tilde{O}(n^{2-2\epsilon/3}) space, for every ϵ∈[0,1/2]\epsilon \in [0, 1/2]. Their algorithm employs separate mechanisms for heavy and light targets, and for each heavy target it stores explicitly the list of pairs (a,b)(a, b) summing to it; these lists dominate the space bound.

We present a unified construction that uses a single mechanism for all queries. Instead of storing these lists of pairs, we recover them on demand by leveraging the Fiat–Naor data structure [SICOMP 1999] to invert the function (a,b)↦(a+bmod  p)(a, b) \mapsto (a + b \mod p). This simplification improves the space bound to O~(nmax⁡(2−ϵ,11/6−ϵ/3))\tilde{O}(n^{\max(2-\epsilon, 11/6-\epsilon/3)}), while maintaining the same query time. Moreover, our construction is the first to achieve subquadratic space while supporting adaptively chosen queries.

1 Introduction

In the 3SUM problem, the input is sets A,B,CA, B, C of nn integers each, and the goal is to determine whether there exists (a,b,c)∈A×B×C(a, b, c) \in A \times B \times C such that a+b+c=0a + b + c = 0. A classical algorithm solves 3SUM in O(n2)O(n^2) time, and current algorithms improve on this bound only by subpolynomial factors [BDP08, Cha20]. The problem is central to fine-grained complexity, where the 3SUM Hypothesis [GO95] asserts that no algorithm can solve 3SUM in O(n2−ε)O(n^{2-\varepsilon}) time for fixed ε>0\varepsilon > 0. It is one of central conjectures in the field and implies conditional quadratic lower bounds for many problems in computational geometry, string algorithms, and dynamic data structures; see [Vas18] for a survey.

In the preprocessed variant of 3SUM, the sets are given as queries, but they are drawn from larger sets of size nn that are known in advance and can be preprocessed. Bansal and Williams [BW12], who attributed the question to Avrim Blum, initiated the study of this problem and gave a data structure with query time n2/polylog(n)n^2/\text{polylog}(n). Subsequent work obtained query times that are truly subquadratic (i.e., smaller than n2n^2 by polynomial factor) for two variants. In the known-C variant, all three sets A,B,CA, B, C are preprocessed, and then a query specifies subsets A′⊆AA' \subseteq A, B′⊆BB' \subseteq B, and C′⊆CC' \subseteq C, asking whether there exists (a,b,c)∈A′×B′×C′(a, b, c) \in A' \times B' \times C' such that

*Email: amir6423@gmail.com

†^{\dagger}Email: yakov.kosoburd@weizmann.ac.il

†^{\dagger}The Harry Weinrebe Professorial Chair of Computer Science. Work partially supported by the Israel Science Foundation grant #1336/23. Email: robert.krauthgamer@weizmann.ac.il

a+b=ca + b = c. In the unknown-C variant, only A and B are preprocessed, and the query specifies subsets A′⊆AA' \subseteq A, B′⊆BB' \subseteq B, and a set C′C' of O(n)O(n) integers, and asks the same question. We focus on the unknown-C variant; observe that it is at least as hard as the known-C one, because a data structure for the former is clearly applicable also for the latter. Throughout, we refer to potential elements of C′C' as targets.

The 3SUM Hypothesis implies that either the preprocessing time or the query time must be at least n2−o(1)n^{2-o(1)}. We therefore allow quadratic preprocessing time and study the query time, particularly its tradeoff with the space occupied by the data structure, called preprocessing space. Our main result obtains the following tradeoff, where O~(f)\widetilde{O}(f) hides logarithmic factors in ff.

Theorem 1.1. For every ε∈[0,1/2]\varepsilon \in [0, 1/2] there is a randomized data structure for preprocessed 3SUM with unknown-C, whose preprocessing runs in O~(n2)\widetilde{O}(n^2) time and occupies space O~(nmax⁡(2−ε,11/6−ε/3))\widetilde{O}(n^{\max(2-\varepsilon, 11/6-\varepsilon/3)}).

The preprocessing succeeds with high probability, in which case every query is answered correctly in worst-case time O~(n3/2+ε)\widetilde{O}(n^{3/2+\varepsilon}).

The two endpoints of the range recover known bounds. At ε=0\varepsilon = 0, the query time is O~(n3/2)\widetilde{O}(n^{3/2}) and the space is O~(n2)\widetilde{O}(n^2), which was previously known [KPS25, KKMV26]. At ε=1/2\varepsilon = 1/2, the query time is O~(n2)\widetilde{O}(n^2) and the space bound is O~(n5/3)\widetilde{O}(n^{5/3}), which matches [KKMV26], although space O(n)O(n) trivially suffices. Between the two endpoints, however, our space bound strictly improves on the best prior bound [KKMV26]. The largest improvement occurs at ε=1/4\varepsilon = 1/4, where our algorithm uses O~(n7/4)\widetilde{O}(n^{7/4}) space, compared with O~(n11/6)\widetilde{O}(n^{11/6}) space of [KKMV26], both with query time O~(n7/4)\widetilde{O}(n^{7/4}).

Besides improving the known space and time bounds, our construction also provides a stronger type of guarantee: Conditioned on successful preprocessing, the data structure answers correctly all possible queries (simultaneously), akin to the "forall" (rather than "foreach") guarantee in sparse recovery and sketching algorithms. It can thus be used in scenarios where an adversary chooses queries adaptively, or based on the data structure (i.e., as a function of the preprocessing phase). In contrast, prior algorithms can only handle an oblivious adversary (see [KKMV26]), i.e., for every fixed query the answer is correct with high probability.

Prior work. Chan and Lewenstein [CL15] achieved the first truly subquadratic query time via additive combinatorics (subsequently extended to real inputs [Fis25]). Chan, Vassilevska Williams, and Xu [CVX23] later improved the query-time and space bounds. Kasliwal, Polak, and Sharma [KPS25] obtained significant improvements for both variants through a much simpler scheme that uses the fast Fourier transform (FFT) for certain counting modulo a random prime.

In the unknown-C variant, however, all data structures with subquadratic query time continued to use quadratic space, essentially by storing information about the full sumset A+BA + B. This barrier was broken by [KKMV26], who gave, for every ε∈[0,1/2]\varepsilon \in [0, 1/2], a data structure with O~(n3/2+ε)\widetilde{O}(n^{3/2+\varepsilon}) query time and O~(n2−2ε/3)\widetilde{O}(n^{2-2\varepsilon/3}) space. We summarize the known bounds and tradeoffs between space and query-time in Figure 1.

Figure

queryspaceunknown CC
n2/polylog(n)n^{2}/\text{polylog}(n)n2n^{2}no[BW12]
n13/7n^{13/7}n13/7n^{13/7}no[CL15]
n1.891n^{1.891}n1.891n^{1.891}no[CVX23]
n3/2n^{3/2}n3/2n^{3/2}no[KPS25]
n1.9n^{1.9}n2n^{2}yes[CL15]
n11/6n^{11/6}n2n^{2}yes[CVX23]
n3/2n^{3/2}n2n^{2}yes[KPS25]
n3/2+εn^{3/2+\varepsilon}n2−2ε/3n^{2-2\varepsilon/3}yes[KKMV26]
n3/2+εn^{3/2+\varepsilon}nmax⁡(2−ε,11/6−ε/3)n^{\max(2-\varepsilon,11/6-\varepsilon/3)}yesTheorem 1.1

Figure 1: Left: The tradeoff between exponents of space and of query-time, for the unknown-C variant. The circles mark the prior unknown-C results, all at quadratic space. The curves meet only at the endpoints. Right: Known bounds for Preprocessed 3SUM, suppressing polylog(n) factors except for [BW12]. All rows take O~(n2)\widetilde{O}(n^2) preprocessing time, which is necessary under the 3SUM Hypothesis.