Abstract 1 Introduction 2 Preliminaries 3 Approximate stabbing queries 4 Spanning trees with low 𝜺-stabbing number 5 Spherical range counting 6 Data-driven range searching References

Space-Efficient Approximate Spherical Range Counting in High Dimensions

Andreas Kalavas ORCID Carnegie Mellon University, Pittsburgh, PA, USA    Ioannis Psarros ORCID Archimedes, Athena Research Center, Greece
Abstract

We study the following range searching problem in high-dimensional Euclidean spaces: given a finite set Pd, where each pP is assigned a weight wp, and radius r>0, we need to preprocess P into a data structure such that when a new query point qd arrives, the data structure reports the cumulative weight of points of P within Euclidean distance r from q. Solving the problem exactly seems to require space usage that is exponential to the dimension, a phenomenon known as the curse of dimensionality. Thus, we focus on approximate solutions where points up to (1+ε)r away from q may be taken into account, where ε>0 is an input parameter known during preprocessing. We build a data structure with near-linear space usage, and query time in n1Θ(ε4/log(1/ε))+tqϱn1ϱ, for some ϱ=Θ(ε2), where tq is the number of points of P in the ambiguity zone, i.e., at distance between r and (1+ε)r from the query q. To the best of our knowledge, this is the first data structure with efficient space usage (subquadratic or near-linear for any ε>0) and query time that remains sublinear for any sublinear tq. We supplement our worst-case bounds with a query-driven preprocessing algorithm to build data structures that are well-adapted to the query distribution.

Keywords and phrases:
Approximate range counting, partition trees, high dimensions
Funding:
Andreas Kalavas: Supported in part by the U.S. National Science Foundation (NSF) Grants ECCS-2145713, CCF-2403194, CCF-2428569, and ECCS-2432545.
Ioannis Psarros: This work has been partially supported by project MIS 5154714 of the National Recovery and Resilience Plan Greece 2.0 funded by the European Union under the NextGenerationEU Program.
Copyright and License:
[Uncaptioned image] © Andreas Kalavas and Ioannis Psarros; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Design and analysis of algorithms
Related Version:
Full Version: https://arxiv.org/abs/2603.12106
Acknowledgements:
We would like to thank Dimitris Fotakis for valuable discussions on the topic.
Editors:
Hee-Kap Ahn, Michael Hoffmann, and Amir Nayyeri

1 Introduction

Range searching is a fundamental problem with wide applications in areas such as computational geometry [13], databases [36], geographic information systems (GIS) [25], and computer graphics [4]. One fundamental variant of range searching is that of range counting, where given a dataset P, we need to preprocess it into a data structure so that for a query range Rq, we can efficiently estimate |RqP|. Primary examples of types of query ranges include rectangles, balls, halfspaces, and simplices.

In this paper, we study the special case of range counting queries for Euclidean balls of fixed radius. Solving the problem exactly seems to require space usage that is exponential to the dimension, a phenomenon known as the curse of dimensionality. Therefore, aiming for solutions that scale well with the dimension, we focus on approximate solutions where points up to (1+ε)r away from q may be considered, where ε>0 is an input parameter known during preprocessing. Formally, given as input a dataset Pd, such that each point pP is assigned a weight wp, search radius r>0, and approximation parameter ε>0, the approximate spherical range counting problem is to preprocess P into a data structure that given any query point qd, it reports wS=pSwp, where SP is a subset such that B(q,r)PSB(q,(1+ε)r)P, where, for any xd, r>0, B(x,r) denotes the Euclidean ball of radius r centered at x. Since we can uniformly rescale the dataset, we assume throughout the paper that the search radius is 1.

Related work.

We juxtapose the above problem definition with a different notion of approximate counting, adapted for example by Aronov and Har-Peled [10], where one is interested in approximating the number of points inside a query range. Given a query range Rq, the data structure shall return a value ν such that (1ε)|RqP|ν(1+ε)|RqP|. Aronov and Har-Peled [10] show that one can reduce such a counting query to a sequence of “emptiness” queries, determining if the query range is empty or not, of length polynomial in log|P| and ε1. In contrast, our definition asks for an exact aggregate over a set whose geometry is allowed to vary within the annulus B(q,1+ε)B(q,1). This definition has been used, e.g., by Arya and Mount [11], although they study solutions in the low-dimensional regime.

In terms of known solutions, approximate spherical range counting in high dimensions is not clearly distinguished from other variants of approximate range searching. Perhaps the most promising approach for related problems in high dimensions is locality sensitive hashing (LSH) (see [26, 20, 6, 8]), which maps the points to buckets with the promise that near (resp. far) points are more (resp. less) likely to be mapped together. It is not clear how one could use an LSH-based approach to solve the counting variant without paying at least the cost of exploring all points in B(q,1). This suggests that, within LSH-based frameworks, counting is unlikely to admit a fundamentally more efficient solution than reporting. In this work, we focus on designing solutions better suited to the counting variant.

Our Results.

Our main contribution is to design a data structure for the approximate range counting problem in high-dimensional Euclidean spaces. For any constant approximation parameter ε(0,1), our data structure uses near-linear space, polynomial preprocessing time, and query time that is sublinear for any sublinear number of points in the ambiguity zone, i.e., for any sublinear tq=|(B(q,1+ε)B(q,1))P| the query time is sublinear.

Our approach is reminiscent of classic results for the exact range searching problem in low-dimensional Euclidean spaces. In particular, a central notion of our approach is that of partition trees [32, 14]. We adapt well-studied relations between spanning trees with low stabbing numbers (which also appears as “crossing” in previous works) and partition trees (see, e.g., [15]) to our approximate setting. A key difference in our setting is that we use a stronger notion of stabbing; we say that a point q ε-stabs a set S if xS:xq1 and yS:yq1+ε (classic stabbing would correspond to the case where ε=0). An important step in our preprocessing algorithm is finding a “light” edge, i.e., a pair of input points that is ε-stabbed by a polynomial in d ratio of the relevant queries. Then, using the multiplicative weight update (MWU) method in a similar manner as [38, 15, 39], we are able to show that we can compute a spanning tree with low ε-stabbing number, implying that we can build a partition tree such that for any query, we only need to visit a bounded number of nodes. To traverse the partition tree, we need to be able to decide for each internal node if the corresponding subset is ε-stabbed by the query. We can only do this approximately, meaning that we may also explore nodes that are almost ε-stabbed, but the overall cost of this exploration is proportional to tq.

Theorem 1 (Simplified version of Theorem 17).

Given a set of n points in d, we can build a randomized data structure for the approximate range counting problem, with space usage in O~(n), preprocessing time in O(dn)+n𝗉𝗈𝗅𝗒(1/ε) and sublinear query time if tq is also sublinear.

Our data structure is the first to achieve space usage that is near-linear in n and polynomial in d, and query time that is sublinear in n and polynomial in d for any sublinear tq. In Table 1, we juxtapose our result with previous known results that even implicitly solve the same problem. While LSH is originally proposed for the approximate near neighbor problem, where the data structure is only required to report one witness point within distance 1+ε, Ahle et al. [2] proposed an LSH-based solution for the problem of reporting all points. Their data structure is adaptive; while building time and space can be that of an LSH table prepared for worst-case inputs (parameter ρ in Table 1), query time is that of the best LSH parameters for the query/instance (parameter b). Moreover, LSH tuned for near-linear space [8] can solve the reporting problem with only a logarithmic overhead in space and query time, since we can amplify the probability that every near neighbor will eventually be encountered. Since both LSH-based methods can solve the reporting variant, they can also solve the counting problem. However, it is not clear whether one can modify such an approach to avoid looking into all near points. Although our result does not guarantee sublinear query time in the worst case, it advances prior space-efficient work in high dimensions by making the complexity depend on the number of points in the annulus rather than on all points inside the entire ball. Trivially, the bucketing method, when combined with a Johnson-Lindenstrauss dimension reduction (as in [20]), can solve the counting problem; after reducing the dimension, one can store the relevant information in grid cells near the dataset. Such methods that discretize the query space, while providing efficient query times, unavoidably have huge space requirements. Finally, when the dimension is constant, partition trees [14] solve the problem exactly, while BBD-trees [11] leverage improved query times for approximate solutions (although still exponential in d).

In addition to our worst-case guarantees, we present an algorithm inspired by learning theory. Specifically, this algorithm is query-driven, i.e., it receives a number of query samples and aims to construct the data structure that yields the best expected query runtime for the distribution of the queries. This way, we design a much faster preprocessing algorithm (from n𝗉𝗈𝗅𝗒(1/ε), the complexity falls to nO(1)), which gives us similar bounds for the average case.

Our approach is motivated by the viewpoint of analyzing algorithms through the lens of statistical learning (e.g., [19, 12]). While this has been influential in optimization and mechanism design, to the best of our knowledge, a similar treatment for data structures is absent. Although related ideas appear in learned index structures [31], LSH trees whose cutting rules are optimized with respect to the given dataset [7], learning-augmented binary trees with optimized search assuming access to advice from a frequency estimation oracle [30], these works do not directly cast the data structure construction itself as a PAC learning problem. We also remark that the related notions of self-improving [3] and instance-optimal algorithms [1] address different guarantees. A simplified version of our result follows:

Theorem 2 (Simplified version of Theorem 20).

Given a set of n points in d and a sample of O(ndlogn) queries from a query distribution 𝒟Q, we can compute a partition tree 𝒯~ with near-optimal expected visiting number for 𝒟Q in O(n3dlogn) time with high probability.

We believe this is a neat way to use tools from other areas to design efficient algorithms for difficult problems or problems with only existence guarantees, and it would be interesting to see what other data-structure problems might benefit from this viewpoint.

Organization.

In Section 2 we present notation and useful known results and prove auxiliary lemmas that will be used later. In Section 3 we analyze a data structure that supports approximate stabbing queries. Subsequently, in Section 4 we prove that a spanning tree with sublinear ε-stabbing number exists and can be computed in polynomial time, which we then use to prove that a partition tree with sublinear query time can be efficiently constructed in Section 5. In Section 6 we present our data-driven algorithm for building a partition tree with near-optimal expected visiting number. Missing proofs can be found in the full version.

Table 1: Existing solutions for the approximate range counting problem. k denotes the number of points within distance 1+ε from the query, whereas tk denotes the number of points at distance between 1 and 1+ε from the query. Adaptive LSH uses a worst-case choice of LSH exponent ρ, but answers queries with an instance-best LSH exponent b.
Method Space Prep. time Query time
LSH [8] n1+o(1) n1+o(1) n1Θ(ε2)+o(1)+kno(1)
Adaptive LSH [2] O~(n1+ρ) O~(n1+ρ) O(k(n/k)b)
Bucketing + JL [20] npoly(1/ε) npoly(1/ε) O(ε2logn)
BBD-Trees [11] O(dn) O(dnlogn) O(logn)+O(1/ε)d1
Partition trees [14] O(dn) O(dn) O(n11/d)
Theorem 20 O~(n) npoly(1/ε) n1Θ(ε4/log(1/ε))
+tΘ(ε2)n1Θ(ε2)

2 Preliminaries

We use the O~ notation to hide the dependence on poly(logn,log(1/ε)). For any δ>0, let 𝒢δd={δvvd} be the grid of side length δ. Unless stated otherwise, denotes the Euclidean norm 2. For any pd and r>0, B(p,r) denotes the Euclidean ball centered at p, i.e., B(p,r)={xdxpr}.

We say that a set of points P is (ε,r)-stabbed by a point p, if and only if there exists a point xP such that xp(1+ε)r and there exists a point yP such that ypr. We say that a pair of points x,y (or an edge formed by them) is (ε,r)-stabbed by p, if and only if {x,y} is (ε,r)-stabbed by p. For brevity, when r=1, we say that a pair x,y is ε-stabbed by p if and only if it is (ε,1)-stabbed by p. Given some Pd and an edge set G (if G is a graph, we refer to its edges), σ(q,G) denotes the ε-stabbing number of q on G, i.e., the number of edges in G that are ε-stabbed by q.

A partition tree 𝒯 built on a set of points P is a tree where each node v is associated with a subset PvP, and for each node v with children u1,,u, we have Pv=iPui and ijPuiPuj=. For a partition tree 𝒯, and a query q, the visiting number of 𝒯 w.r.t. q, denoted by ζ(q,𝒯) is the number of nodes v in 𝒯 which are either root of 𝒯 or their parent u satisfies one of the following:

  • Pu is ε-stabbed by q, or

  • Pu(B(q,1+ε)B(q,1)) and PuB(q,1+ε), or

  • Pu(B(q,1+ε)B(q,1)) and PuB(q,1)=.

Intuitively, the visiting number is an upper-bound estimate of the number of nodes that will be visited to answer a query approximately.

2.1 Range spaces

Fix a countably infinite domain set X. The so-called Vapnik-Chernovenkis dimension [34, 35, 37] (VC dimension) of a set of functions from X to {0,1}, denoted by VCdim(), is the largest d such that there is a set S={x1,,xd}X, for which, for any s2S there is a function f such that psf(p)=1. A range space is defined as a pair (X,) where X is the domain and is a set of functions from X to {0,1}, or equivalently a pair of sets (X,), where X is the domain and is a set of ranges, i.e., subsets of X. The dual range space of a range space defined by sets (X,) is a range space defined by sets (,𝒳), where 𝒳={{RxR}xX}. The dual VC dimension of a range space is the VC dimension of its dual. A set NX is an ε-net if R:|RX|ε|X|NR.

Theorem 3 (ε-net theorem [24]).

Let (X,) be a range space of VC-dimension D<, where X is a finite set. There exists a constant C>0 such that for any ε(0,1) if we sample a set of m points (independent picks with uniform probability) from X, where

mC1ε(Dlog1ε+log1δ),

then, with probability at least 1δ, the resulting set is an ε-net for (X,).

For any S=(x1,,xm)Xm let μf(S)=m1i=1mf(xi). For any η>0,r0,s0, let dη(r,s)=|rs|η+r+s. By properly adjusting the parameters in Theorem 3.1 of [29], we obtain the following corollary. A similar result is obtained in [23].

Corollary 4.

Let X be a countably infinite domain. Let be a set of functions from X to {0,1} with VC dimension D and let 𝒟 be a probability distribution over X. Also, let δ,η(0,1). There is a universal constant c such that if mcη(Dlog(1η)+log(1δ)) then if we sample S={x1,,xm} independently at random according to 𝒟, then with probability at least 1δ, for any f,

|μf(S)𝔼p𝒟[f(p)]|(3/8)max{𝔼p𝒟[f(p)],η}.

A key requirement in building our data structures is to be able to efficiently sample from a multiset, which can also be updated. A multiset can be seen as a weighted set where weights correspond to multiplicities. In the following lemma, we show that one can maintain a multiset in a data structure that supports sampling and updates on the multiplicities.

Lemma 5.

[Multiset sampling data structure] Let P={p1,,pn}d, and let ε(0,1). Let Γ={γ1,,γn} be weights associated with the points of P. There is an algorithm that preprocesses Γ,P into a data structure, in O(nlogn) time, using O(nlogn) space, which supports the following operations:

  1. 1.

    sampling of a point piP with probability γii[n]γi in O(log(n)) time,

  2. 2.

    update of the weight γi of a point piP, in O(logn) time.

Sampling uses O(log(i[n]γi)) random bits. If bit-complexity were taken into account, both preprocessing and updates would incur an additional O(log(i[n]γi)) bit-cost per arithmetic operation.

2.2 Embeddings

We use the following version of the Johnson-Lindenstrauss (JL) lemma [28], as expressed for a single vector and Gaussian matrices.

Theorem 6 ([27]).

Let xd be fixed and let k. Draw a random matrix Ak×d with i.i.d. entries Aij𝒩(0,1/k). Then for any ε(0,1),

Pr[|Ax22x22|>εx22] 2exp(ε2k8).

We also make use of the following result on terminal embedding for Euclidean spaces.

Theorem 7 ([33]).

Let Td be a finite set of terminals. For every ε(0,1) there exists a mapping f:dk with k=O(ε2log|T|) such that for all qT and all pd,

(1ε)qp2f(q)f(p)2(1+ε)qp2.

For any T, and any c>0, we can compute a mapping f in poly(|T|) time such that the above property holds with probability at least 1nc. Moreover, for any pd, f(p) can be computed in poly(|T|) time.

2.3 Model

We assume that our algorithms operate in the Real-RAM model with the additional assumption that the floor function can be computed in constant time. While it is known that this model is strictly more powerful than the classical word-RAM [16], it is often used in the Computational Geometry literature [22]. We stress that we do not use encodings that pack superpolynomial information into a single machine word or real number, and our use of is purely for convenience (e.g., discretization and bucketing).

One building block of our algorithms is a data structure known as the dictionary. A dictionary is a data structure which stores a set of (key, value) pairs and when presented with a key, either returns the corresponding value, or returns that the key is not stored in the dictionary. In our case, keys are typically vectors in d and values are pointers to lists. In the Real-RAM model, we can use a balanced binary tree to build a dictionary with n values, using O~(dn) preprocessing time and storage and O~(d) query time.

3 Approximate stabbing queries

In this section, we design a solution for our main subproblem, that is, the problem of preprocessing a set of points to support queries that ask to determine if a query ε-stabs the given pointset. In particular, the data structure is required to determine if the query ε-stabs the pointset, if all points are near the query, or if all points are far from the query. The resulting data structure returns approximate answers, meaning that it allows for wrong decisions when the pointset is “nearly” ε-stabbed, as formalized in Theorem 10. This is sufficient for our purposes, which are building these data structures in internal nodes of a partition tree to assist in traversing the tree to answer a query.

Our main technical ingredient is a randomized embedding to the Hamming metric, which is implemented using LSH to partition the space into buckets and then applying random binarization of the buckets. A similar argument has been used in Alman et al. [5], where they first embed the points to 1 and then use an LSH function to partition points into buckets; each bucket is then assigned to a random bit. Repeating the above sufficiently many times gives the desired embedding. We obtain a slightly more direct construction that does not need to embed the points in 1, but instead uses the LSH family of Datar et al. [18]. The final embedding succeeds in preserving distances with respect to a single scale; distances considered small with respect to a given threshold remain small, and large distances remain large. This is formally stated in the following lemma.

Lemma 8.

For any δ,ε(0,1), there exists a randomized embedding f:d{0,1}d, and specific θ[d], such that, for any p,qd, with probability at least 1δ,

  • if pq1 then Pr[f(p)f(q)1>θ]eε2d19200

  • if pq(1+ε) then Pr[f(p)f(q)1<θ+εd]eε2d19200.

Moreover, for any pd, f(p) can be computed in O(d) running time.

We aim to build a data structure that supports approximate “stabbing queries”. Given a query point q we need to identify if there exists a pair of points in the input pointset that are (approximately) ε-stabbed by q. Using the embedding of Lemma 8, we map points to keys in {0,1}d, and we store them in a dictionary, where each bucket is assigned the list of points mapped to it. We set d slightly below logn to balance the number of buckets 2d with the number of arbitrarily distorted distances from q, in a way that both remain sublinear. To answer a query, we search the dictionary for an approximate near neighbor, i.e., a point within distance 1+ε, and an approximate far neighbor, i.e., a point at a distance of at least 1. The following lemma indicates that a simple search over the buckets of a single dictionary is sufficient to guarantee that if there is a point within distance 1, we will find a point within distance 1+ε with constant probability, and if there is a point at distance at least 1+ε, we will find a point at distance at least 1 with constant probability. We remark that for finding an approximate near neighbor, one could instead use the data structure of Andoni et al. [8] that provides near-linear space with comparable query time. However, we are not aware of a comparable result for computing an approximate far neighbor (which we also need and do).

Lemma 9.

Let P={p1,,pn}d and let ε(0,1). We can build a randomized data structure with preprocessing time and space in O~(dn) and query time in O~(dn1ε219200(1+ε2)), such that for any query qd, it reports , ||2, as follows:

  • if xP:xq1 then Pr[i such that qpi1+ε]0.95,

  • if yP:yq1+ε then Pr[j such that qpj1]0.95,

where the probabilities are taken over the randomness during preprocessing.

Now using Lemma 9, we can prove the main result of this section, namely, a data structure that determines, with high probability, if a query point ε-stabs the preprocessed pointset, if it is near the entire pointset (the pointset is covered by q), or if it is far from the entire pointset (the pointset is disjoint from q). The data structure gives approximate answers in the following sense: if all points are within distance 1+ε, and there is at least one point at a distance at most 1, it can falsely report that the pointset is ε-stabbed. Similarly, if all points are at a distance larger than 1, and there is at least one point at a distance of at least 1+ε, it can falsely report that the pointset is ε-stabbed. If all points lie in the annulus {xdxq(1,1+ε)} then any answer is possible. Additionally, the success probability of the preprocessing is for each query individually, i.e., it is not for all queries simultaneously. Copies of this structure will be used as parts of the final data structure for the approximate spherical range counting problem.

Theorem 10.

Let Pd be a set of n points and let ε(0,1). We can build a randomized data structure such that for any query qd, it reports as follows:

  • if xP:xq1 and yP:yq1+ε then it returns “stabbed”,

  • if yP:yq1 then it returns “covered”

  • if xP:xq1+ε then it returns “disjoint”,

  • if xP:xq1 and yP:yq<1+ε then it can return “stabbed”, or “covered”, and

  • if xP:xq1+ε and yP:yq>1 then it can return “stabbed”, or “disjoint”.

  • if xP:xq(1,1+ε) then it can return “stabbed”, or “disjoint”, or “covered”.

For each query and for any constant c>0, the preprocessing of the data structure succeeds with probability 1nc, has O~(dn) preprocessing time and space and the query time is O~(dn1ε219200(1+ε2)).

Proof.

We build L=clogn independent data structures as in Lemma 9. For any query point qd, we query the data structures, and we report as follows. If we find a point x such that xq1+ε and a point y such that yq1 we return “stabbed”. Otherwise, if all returned points are within distance 1+ε, we return “covered”. Else, we return “disjoint”.

If there is a pair x,y in P such that xq1 and yq1+ε then the probability that all L data structures fail to return a point x such that xq1+ε or a point y such that yq1 is by union bound at most 20.05Lnc. Moreover, if all points of P are within distance 1 from q (resp. at a distance of at least 1+ε), then all returned points are within distance 1+ε from q (resp. at a distance of at least 1), implying that the query algorithm correctly identifies “covered” (resp. “disjoint”).

4 Spanning trees with low 𝜺-stabbing number

The ε-stabbing number of a spanning tree (or of a set of edges in general) is the maximum number of edges of that tree (or that set) that are ε-stabbed by any query range. Chazelle and Welzl showed in [15] a close relationship between the stabbing number of a spanning tree (the stabbing number is the special case of ε-stabbing number where ε=0) and the maximum number of nodes visited, during a worst-case query, in a corresponding partition tree. Motivated by this, we wish to extend this notion to the ε-stabbing number and to achieve similar results, but without exponential dependency on d as we deal with the approximation scheme. In this section, we show that a spanning tree with sublinear ε-stabbing number exists, and can be computed in polynomial time. Following [15], we use MWU to find a spanning tree with small ε-stabbing number. We remark that there are other alternatives [17, 21] in the literature for computing spanning trees with low stabbing numbers. While it is plausible that they can be modified to support our notion of ε-stabbing, they all share the same bottleneck, i.e., they depend at least linearly on the number of ranges.

Similarly, to [15], we start by showing that for any set of ball queries, we can always find a pair of points that is not ε-stabbed many times.

Lemma 11.

Let Pd be a set of n points and let Q be a multiset consisting of m points from a universe set Ud. Let ε(0,1). There exists a pair of points in P which is not ε-stabbed by more than O(mdnρ) points of Q, where ρ=Θ(ε2/log(1/ε)).

If Q is stored in a multiset sampling data structure as in Lemma 5, then for any constant c, we can find such a pair of points in poly(n,d,1ε)O(log|U|) time with probability 1nc.

Proof.

If dnρ, then the statement trivially holds, since |Q|=m. Thus, we assume d<nρ. For any two points x,y, let Sx,y be the set of points in d that ε-stab x,y. We define a range space =(d,{Sx,yx,yd,xy}). Notice that for any point pd, determining if pSx,y reduces to evaluating the signs of the following four polynomials of degree 2 in d variables: px21, px2(1+ε)2, py21, py2(1+ε)2. This implies (see, e.g., [9][Theorem 8.3]) that the VC dimension of is O(d). Hence, by Theorem 3, for any δ<1 and constant c>0, a random sample Nδ of O(dδ(log(1δ)+logn)) points of Q is a δ-net for with probability 1nc1. Moreover, we can find such a δ-net by randomly sampling from Q, using the assumed multiset sampling data structure of Lemma 5, in O~(dδlogn)O(log|U|) time.

By Theorem 7, there exists a terminal embedding f to dimension d=O(ε2log|Nδ|) such that pNδ,qd, f(p)f(q)(1±ε/20)pq. The time needed to compute f(P) is in O(n)poly(|Nδ|) for the probability of success to be at least 1nc1.

Now let x,yP be ε-stabbed by some qQ, and further assume wlog that xq1 and yq1+ε. We obtain f(x)f(q)1+ε/20 and f(y)f(q)(1+ε)(1ε/20)1+3ε/4. Hence, f(x),f(y) are (ε/2,1+ε/20)-stabbed by f(q). Moreover, by the triangle inequality, f(x)f(y)ε/2. Now consider the grid of side-length ε/(4d) in d and let UB be the set of all grid cells that intersect with at least one ball of radius 1+ε centered at a point of f(Nδ). There are

nε,d=|Nδ|O(1/ε)d=|Nδ|O(1/ε)O(ε2log|Nδ|)=|Nδ|O(ε2log(1/ε))

such cells, where |Nδ|=O(dδ(log(1δ)+logn)). Now let δ=dnρ where ρ=Θ(ε2/log(1/ε)) is chosen sufficiently small (in terms of the hidden constants) so that |Nδ|O(ε2log(1/ε))(nρlogn)O(ε2log(1/ε))<n2. By the pigeonhole principle, there is either a pair of points of P mapped to the same cell of UB, under f, or there is a pair of points of P that are not mapped to UB. In either case, the two points are not (ε/2,1+ε/20)-stabbed by any point of f(Nδ). To see this, notice that if the two points are in the same cell, then they are within distance ε/4 from each other, contradicting the fact that they are (ε/2,1+ε/20)-stabbed (which would mean they are separated by a distance of at least ε/2). If they are not mapped in UB then neither of them is within distance 1+ε/20 from any point of f(Nδ), also implying that they cannot be (ε/2,1+ε/20)-stabbed by any point of f(Nδ). Since the two points are not (ε/2,1+ε/20)-stabbed by any point of f(Nδ) in the mapped space, their pre-images (under f) are not ε-stabbed by any point of Nδ. Since Nδ is a δ-net, it must be that at most δm points of Q ε-stab those two points.

We now focus on the running time needed to find a pair of points as above. By Theorem 7, we can map points under f in poly(n) time. To compute the two points, we essentially use the bucketing method (see, e.g., [20]) for balls centered at f(Nδ). We first store all cells of UB in a dictionary data structure. Then, for each point xf(P), we query the data structure to see if its cell Cx is stored, i.e., CxUB. If CxUB then we store x in a linked list in the bucket of Cx. We can stop and output any two points stored in the same linked list, or any two points whose cells do not belong to UB. Iterating over all points of f(P) costs O~(dn) assuming that the dictionary is implemented using balanced binary trees. The overall probability of success follows from a union bound over failure events of the random sampling for computing Nδ and the failure event of computing the terminal embedding f.

Knowing that a good pair exists, and that we can find it, we repeat the process n/2 times, in order to build a good forest, in the sense that it has a small ε-stabbing number. We use the MWU technique introduced in the context of trees with low stabbing number in [15].

Lemma 12.

Let Pd be a set of n points and let ε(0,1). There is a forest of trees on P with at least n/2 edges, such that every point of 𝒢γd ε-stabs O~(dn1ρ) edges, where γ=Θ(ε/d), ρ=Θ(ε2/log(1/ε)). For any c>0, we can compute such a forest in poly(n,d,1ε))+O~(n)O(1/ε)d time, with probability of success 1nc.

We conclude with the main result of this section, the tractability of a spanning tree with a sublinear ε-stabbing number. This follows from O(logn) iterative applications of Lemma 12.

Theorem 13.

Let Pd be a set of n points. There is a spanning tree on P such that every point of 𝒢γd ε-stabs O~(dn1ρ) edges, where γ=Θ(ε/d), ρ=Θ(ε2/log(1/ε)).

Moreover, for any c>0, we can compute such a spanning tree in poly(n,d,1ε)+O~(n)O(1/ε)d time, with probability of success 1nc.

5 Spherical range counting

In this section, we show how to construct a partition tree for the approximate spherical range counting problem with sublinear query time. We first show how to get a partition tree with a sublinear visiting number given a spanning tree with a sublinear ε-stabbing number, by extending the procedure in [15] to accommodate the approximation scheme. Subsequently, we incorporate the data structures of Section 3 in the inner nodes of the partition tree to get sublinear worst-case guarantees.

We start by proving that having a spanning tree with low ε-stabbing number can give us a spanning path with low ε-stabbing number, which we then use to construct a partition tree with low visiting number. Lemmas 14 and 15 are adapted from [15] for ε-stabbing numbers, and the bounds become dependent on the ambiguity zone of the query.

Lemma 14.

Given a spanning tree T on a pointset Pd, we can build a spanning path 𝒫 on P, in O(dn) time, such that for any point q, σ(q,𝒫)2σ(q,T)+2tq, where tq=|(B(q,1+ε)B(q,1))P|.

Lemma 15.

Given a spanning path 𝒫 on a pointset Pd we can build a binary partition tree 𝒯 on P, in (dnlogn) time, such that for any point q, we have ζ(q,𝒯)2[σ(q,𝒫)+tq]logn+1, where tq=|(B(q,1+ε)B(q,1))P|.

We combine these results to get a bound on the visiting number of a partition tree.

Corollary 16.

Let Pd be a set of n points. For any c>0, we can build a binary partition tree 𝒯 on P, in poly(n,d,1ε)+O~(n)O(1/ε)d time such that with probability 11/nc every q𝒢γd, with γ=ε/d, visits ζ(q,𝒯)=O~(dn1ρ+tq) nodes, where tq=|(B(q,1+ε)B(q,1))P| and ρ=Θ(ε2/log(1/ε)).

Finally, we present the main contribution of our paper, which states that for the approximate spherical range counting problem, we can build a data structure in polynomial time that supports sublinear queries (if tq is also sublinear) and takes near-linear space. In our proof, we make use of Theorems 10, 13, and 15.

Theorem 17.

Let Pd be a set of n points, such that each pP is assigned a weight wp, and let ε(0,1). We can build a data structure for the approximate range counting problem with input P,{wppP},ε, that uses space in O~(n), needs preprocessing time in O(dn)+nO(ε2log(1/ε)) and for each query qd, it returns an answer in n1Θ(ε4/log(1/ε))+tqϱn1ϱ time, where ϱ=Θ(ε2) and tq=|(B(q,1+ε)B(q,1))P|. For each query, the preprocessing succeeds with probability 1nc, where c>0 is a constant hidden in the aforementioned time and space complexities.

Proof.

We first apply a JL transformation [28] to reduce the dimension to O(ε2logn). By Theorem 6, and by applying a union bound over n vectors, for any c>0 and any query qd, with probability 11/nc, all distances from P are approximately preserved within factors 1±ε/10. This initial step costs O(dn) time. For the rest of the proof, we assume that all points lie in O(ε2logn). Then, we assume that queries are snapped to the grid 𝒢γd, γ=ε/(10d). This induces an additive ±ε/10 error to the distances between P and the query. Hence, points within distance 1 from the query may be moved to a distance up to 1+ε/5, and points at a distance of at least 1+ε may be moved to a distance of at least 1+4ε/5. Notice that 1+ε/21+4ε/51+ε/5, hence it suffices to use a more refined error of ε/2 for the rest of the construction and assume that the space is rescaled by a factor 1/(1+ε/5).

We build a binary partition tree 𝒯 on the input with error parameter ε/2 using Corollary 16. The construction of 𝒯 can be done in nO(ε2log(1/ε)) time and be successful for a fixed q, in that ζ(q,𝒯)n1Θ(ε2/log(1/ε))+tq, with probability 11/nc for any constant c>0. For each internal node v, let Pv be the set of points in the leaves of the subtree rooted at v. In each internal node v, we build a data structure 𝒟v as in Theorem 10 on Pv with error parameter ε/2, and we store the cumulative weight sv of the points in Pv, i.e., sv=pPvwp. By Theorem 10, each construction of a data structure 𝒟v, can be done in O~(d|Pv|) time and be successful with probability 11/nc for any constant c>0. By a union bound over all inner nodes, we claim that all data structures 𝒟v are also successful for q with probability 1Θ(nlognnc). By Theorem 10, the time and space needed to build data structures for the inner nodes is near-linear per level of the tree (since each level defines a partition).

To answer a query qd, we traverse the tree and collect all cumulative weights sv in each internal node v, whose associated data structure 𝒟v returns “covered”. We continue traversing the children of a node v if and only if 𝒟v returns “stabbed”. By Corollary 16, assuming that the tree has been constructed correctly for qd, the number of nodes visited during the query algorithm for input qd is O~(nα+tq), where α=1Θ(ε2/log(1/ε)). By Theorem 10, the time needed to query a data structure 𝒟v in an internal node v is O~(|Pv|β), where β=1Θ(ε2). At each level i of 𝒯, the number of nodes whose data structures are queried is upper bounded by both 2i and ζ(q,𝒯). Hence, the running time at level i for query q is O~(Tiq(n)), where Tiq(n) is defined as follows:

Tiq(n)=min{ 2i,nα+tq}(n2i)β(nα+tq)1βnβ,

because if ilog(nα+tq) then min{ 2i,nα+tq}=2i and if i>log(nα+tq) then min{ 2i,nα+tq}=nα+tq. Now, since 1β<1,

Tiq(n)nα(1β)+β+tq1βnβ=n1Θ(ε4/log(1/ε))+tqϱn1ϱ,

where ϱ=1β. We observe that the query algorithm will not explore any descendants of an internal node v if 𝒟v returns “disjoint” when minxPvxq>1, or if 𝒟v returns “covered” when maxxPvxq1+ε/2, in which case it takes into account sv. Thus, the answer is calculated by summing over cumulative weights sv1,,sv of nodes corresponding to subsets Pv1,,Pv such that B(q,1)Pi[]PviB(q,1+ε/2)P.

6 Data-driven range searching

As we saw in the previous section, we can construct the partition tree in polynomial time. However, the exponent depends on 1/ε, which we would like to avoid. In this section, we present an algorithm inspired by learning theory that constructs a partition tree with near-optimal visiting number in expectation, over the distribution of queries. Specifically, the algorithm will have access to a number m of sample queries, and will construct a partition tree that is optimal for that sample - thus the algorithm is data-driven. Showing that uniform convergence is achieved, we prove that this partition tree is nearly optimal, in that its expected visiting number is nearly minimal.

In the next lemma, we show that using only a near-linear number of queries we can achieve uniform convergence for the expected ε-stabbing number, i.e., for any spanning tree, the estimation of the ε-stabbing number using only these queries is close to its real expected ε-stabbing number.

Lemma 18.

Let P be a set of n points in d and let 𝒟Q be a ball query distribution having as support a countably infinite set . It suffices to sample mO(n(dlogn+log(1/δ))) queries S independently from 𝒟Q, so that with probability at least 1δ, for any spanning tree T of P, m1qSσ(q,T) is in [58𝔼q𝒟Q[σ(q,T)]38,118𝔼q𝒟Q[σ(q,T)]+38].

The next lemma states that the number of nodes of a partition tree visited during a query search consists an upper bound on the ε-stabbing number of a corresponding spanning path of the points for the same query. Its proof is a straightforward adaptation of the third item of [15, Lemma 3.1].

Lemma 19.

If 𝒯 is a partition tree for P, then there exists a spanning path 𝒫 whose ε-stabbing number does not exceed the visiting number of 𝒯.

We now prove the main result of this section.

Theorem 20.

Let P be a set of n points in d and let 𝒟Q be a ball query distribution having as support a countably infinite set . It suffices to sample a set S of mO(n(dlogn+log(1/δ))) queries independently from 𝒟Q, so that with probability at least 1δ, we can compute a partition tree 𝒯~ such that

𝔼q𝒟Q[ζ(q,𝒯~)]=O([min𝒯𝔼q𝒟Q[ζ(q,𝒯)]+tq]logn),

where tq=|(B(q,1+ε)B(q,1))P|. Moreover, given S, the running time to compute 𝒯~ is in O(n3(dlogn+log(1/δ)).

Proof.

By Lemma 18, with probability at least 1δ, for any spanning tree T of P, m1qSσ(q,T) is in

[58𝔼q𝒟Q[σ(q,T)]38,118𝔼q𝒟Q[σ(q,T)]+38].

Now, let E(T) denote the edges of spanning tree T and T~=argminT{m1qSσ(q,T)}. Notice that qSσ(q,T)=qSeE(T)σ(q,{e})=eE(T)qSσ(q,{e}) for any spanning tree T. Hence, we can compute T~, by first constructing a complete weighted graph on P where we assign weight qSσ(q,{e}) to each edge e(P2), and then computing the minimum spanning tree on that graph, using Kruskal’s algorithm. The running time of this step is O(n2m), which corresponds to the step of building the graph.

Let T be the spanning tree that minimizes 𝔼q𝒟Q[σ(q,T)] over all spanning trees T of P. By Lemma 19 we get 𝔼q𝒟Q[σ(q,T)]min𝒯𝔼q𝒟Q[ζ(q,𝒯)] and by Lemma 18 we get:

Ω(1)𝔼q𝒟Q[σ(q,T~)]m1qSσ(q,T~)m1qSσ(q,T)O(1)𝔼q𝒟Q[σ(q,T)]

Hence 𝔼q𝒟Q[σ(q,T~)]O(min𝒯𝔼q𝒟Q[ζ(q,𝒯)]). Given T~, by Lemmas 14 and 15 we can construct a binary partition tree 𝒯~ of P such that

𝔼q𝒟Q[ζ(q,𝒯~)] =O([𝔼q𝒟Q[σ(q,T~)]+tq]logn)
=O([min𝒯𝔼q𝒟Q[ζ(q,𝒯)]+tq]logn)

in O(n) time. Thus, the overall running time is O(n2m)O(n3(dlogn+log(1/δ)).

References

  • [1] Peyman Afshani, Jérémy Barbay, and Timothy M. Chan. Instance-optimal geometric algorithms. J. ACM, 64(1), 2017. doi:10.1145/3046673.
  • [2] Thomas D. Ahle, Martin Aumüller, and Rasmus Pagh. Parameter-free locality sensitive hashing for spherical range reporting. In Philip N. Klein, editor, Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2017, Barcelona, Spain, Hotel Porta Fira, January 16-19, pages 239–256. SIAM, 2017. doi:10.1137/1.9781611974782.16.
  • [3] Nir Ailon, Bernard Chazelle, Kenneth L. Clarkson, Ding Liu, Wolfgang Mulzer, and C. Seshadhri. Self-improving algorithms. SIAM J. Comput., 40(2):350–375, 2011. doi:10.1137/090766437.
  • [4] Tomas Akenine-Möller, Eric Haines, Naty Hoffman, Angelo Pesce, Michał Iwanicki, and Sébastien Hillaire. Real-Time Rendering 4th Edition. A K Peters/CRC Press, Boca Raton, FL, USA, 2018.
  • [5] J. Alman, T. M.Chan, and R. R. Williams. Polynomial representations of threshold functions and algorithmic applications. In IEEE 57th Annual Symposium on Foundations of Computer Science, FOCS 2016, 9-11 October 2016, Hyatt Regency, New Brunswick, New Jersey, USA, pages 467–476, 2016. doi:10.1109/FOCS.2016.57.
  • [6] A. Andoni and P. Indyk. Near-optimal hashing algorithms for approximate nearest neighbor in high dimensions. Commun. ACM, 51(1):117–122, 2008. doi:10.1145/1327452.1327494.
  • [7] Alexandr Andoni and Daniel Beaglehole. Learning to hash robustly, guaranteed. In Kamalika Chaudhuri, Stefanie Jegelka, Le Song, Csaba Szepesvári, Gang Niu, and Sivan Sabato, editors, International Conference on Machine Learning, ICML 2022, 17-23 July 2022, Baltimore, Maryland, USA, volume 162 of Proceedings of Machine Learning Research, pages 599–618. PMLR, 2022. URL: https://proceedings.mlr.press/v162/andoni22a.html.
  • [8] Alexandr Andoni, Thijs Laarhoven, Ilya P. Razenshteyn, and Erik Waingarten. Optimal hashing-based time-space trade-offs for approximate near neighbors. In Philip N. Klein, editor, Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2017, Barcelona, Spain, Hotel Porta Fira, January 16-19, pages 47–66. SIAM, 2017. doi:10.1137/1.9781611974782.4.
  • [9] Martin Anthony and Peter L. Bartlett. Neural Network Learning - Theoretical Foundations. Cambridge University Press, 2002. URL: http://www.cambridge.org/gb/knowledge/isbn/item1154061/?site_locale=en_GB.
  • [10] Boris Aronov and Sariel Har-Peled. On approximating the depth and related problems. SIAM Journal on Computing, 38(3):899–921, 2008. doi:10.1137/060669474.
  • [11] Sunil Arya and David M. Mount. Approximate range searching. Comput. Geom., 17(3-4):135–152, 2000. doi:10.1016/S0925-7721(00)00022-5.
  • [12] Maria-Florina Balcan, Dan F. DeBlasio, Travis Dick, Carl Kingsford, Tuomas Sandholm, and Ellen Vitercik. How much data is sufficient to learn high-performing algorithms? J. ACM, 71(5):32:1–32:58, 2024. doi:10.1145/3676278.
  • [13] Mark de Berg, Otfried Cheong, Marc van Kreveld, and Mark Overmars. Computational Geometry: Algorithms and Applications. Springer-Verlag TELOS, Santa Clara, CA, USA, 3rd ed. edition, 2008.
  • [14] Timothy M Chan. Optimal partition trees. In Proceedings of the twenty-sixth annual symposium on Computational geometry, pages 1–10, 2010. doi:10.1145/1810959.1810961.
  • [15] Bernard Chazelle and Emo Welzl. Quasi-optimal range searching in space of finite VC-dimension. Discret. Comput. Geom., 4:467–489, 1989. doi:10.1007/BF02187743.
  • [16] Qi Cheng. On comparing sums of square roots of small integers. In Proceedings of the 31st International Conference on Mathematical Foundations of Computer Science, MFCS’06, pages 250–255, Berlin, Heidelberg, 2006. Springer-Verlag. doi:10.1007/11821069_22.
  • [17] Mónika Csikós and Nabil H. Mustafa. Escaping the curse of spatial partitioning: Matchings with low crossing numbers and their applications. In Kevin Buchin and Éric Colin de Verdière, editors, 37th International Symposium on Computational Geometry, SoCG 2021, June 7-11, 2021, Buffalo, NY, USA (Virtual Conference), volume 189 of LIPIcs, pages 28:1–28:17. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2021. doi:10.4230/LIPIcs.SOCG.2021.28.
  • [18] Mayur Datar, Nicole Immorlica, Piotr Indyk, and Vahab S. Mirrokni. Locality-sensitive hashing scheme based on p-stable distributions. In Jack Snoeyink and Jean-Daniel Boissonnat, editors, Proceedings of the 20th ACM Symposium on Computational Geometry, Brooklyn, New York, USA, June 8-11, 2004, pages 253–262. ACM, 2004. doi:10.1145/997817.997857.
  • [19] Rishi Gupta and Tim Roughgarden. A PAC approach to application-specific algorithm selection. SIAM J. Comput., 46(3):992–1017, 2017. doi:10.1137/15M1050276.
  • [20] S. Har-Peled, P. Indyk, and R. Motwani. Approximate nearest neighbor: Towards removing the curse of dimensionality. Theory of Computing, 8(1):321–350, 2012. doi:10.4086/toc.2012.v008a014.
  • [21] Sariel Har-Peled. Approximating spanning trees with low crossing number, 2009. arXiv:0907.1131.
  • [22] Sariel Har-peled. Geometric Approximation Algorithms. American Mathematical Society, USA, 2011.
  • [23] Sariel Har-Peled and Micha Sharir. Relative (p,ϵ)-Approximations in Geometry. Discrete & Computational Geometry, 45(3):462–496, April 2011. doi:10.1007/S00454-010-9248-1.
  • [24] David Haussler and Emo Welzl. ε-nets and simplex range queries. Discrete & Computational Geometry, 2:127–151, 1987. URL: https://api.semanticscholar.org/CorpusID:27638326.
  • [25] O. Huisman and R.A. de By. Principles of geographic information systems : an introductory textbook. ITC Educational Textbook Series. International Institute for Geo-Information Science and Earth Observation, Netherlands, 2009.
  • [26] P. Indyk and R. Motwani. Approximate nearest neighbors: Towards removing the curse of dimensionality. In Proc. 30th Annual ACM Symp. Theory of Computing, STOC’98, pages 604–613, 1998. doi:10.1145/276698.276876.
  • [27] P. Indyk and A. Naor. Nearest-neighbor-preserving embeddings. ACM Trans. Algorithms, 3(3), 2007. doi:10.1145/1273340.1273347.
  • [28] William B. Johnson and Joram Lindenstrauss. Extensions of lipschitz mappings into hilbert space. Contemporary mathematics, 26:189–206, 1984. URL: https://api.semanticscholar.org/CorpusID:117819162.
  • [29] Yi Li, Philip M. Long, and Aravind Srinivasan. Improved bounds on the sample complexity of learning. In Proceedings of the Eleventh Annual ACM-SIAM Symposium on Discrete Algorithms, SODA ’00, pages 309–318, USA, 2000. Society for Industrial and Applied Mathematics. URL: http://dl.acm.org/citation.cfm?id=338219.338267.
  • [30] Honghao Lin, Tian Luo, and David P. Woodruff. Learning augmented binary search trees. In Kamalika Chaudhuri, Stefanie Jegelka, Le Song, Csaba Szepesvári, Gang Niu, and Sivan Sabato, editors, International Conference on Machine Learning, ICML 2022, 17-23 July 2022, Baltimore, Maryland, USA, volume 162 of Proceedings of Machine Learning Research, pages 13431–13440. PMLR, 2022. URL: https://proceedings.mlr.press/v162/lin22f.html.
  • [31] Qiyu Liu, Maocheng Li, Yuxiang Zeng, Yanyan Shen, and Lei Chen. How good are multi-dimensional learned indexes? an experimental survey. VLDB J., 34(2):17, 2025. doi:10.1007/S00778-024-00893-6.
  • [32] Jirí Matousek. Efficient partition trees. Discret. Comput. Geom., 8:315–334, 1992. doi:10.1007/BF02293051.
  • [33] Shyam Narayanan and Jelani Nelson. Optimal terminal dimensionality reduction in euclidean space. In Moses Charikar and Edith Cohen, editors, Proceedings of the 51st Annual ACM SIGACT Symposium on Theory of Computing, STOC 2019, Phoenix, AZ, USA, June 23-26, 2019, pages 1064–1069. ACM, 2019. doi:10.1145/3313276.3316307.
  • [34] Norbert Sauer. On the density of families of sets. Journal of Combinatorial Theory Series A, 13:145–147, 1972. doi:10.1016/0097-3165(72)90019-2.
  • [35] Saharon Shelah. A combinatorial problem; stability and order for models and theories in infinitary languages. Pacific Journal of Mathematics, 41(1), 1972.
  • [36] Abraham Silberschatz, Henry Korth, and S. Sudarshan. Database Systems Concepts. McGraw-Hill, Inc., USA, 5 edition, 2005.
  • [37] Vladimir Vapnik and Alexey Chervonenkis. On the uniform convergence of relative frequencies of events to their probabilities. Theory of Probability and its Applications, 16:264–280, 1971.
  • [38] Emo Welzl. Partition trees for triangle counting and other range searching problems. In Herbert Edelsbrunner, editor, Proceedings of the Fourth Annual Symposium on Computational Geometry, Urbana-Champaign, IL, USA, June 6-8, 1988, pages 23–33. ACM, 1988. doi:10.1145/73393.73397.
  • [39] Emo Welzl. On spanning trees with low crossing numbers. In Burkhard Monien and Thomas Ottmann, editors, Data Structures and Efficient Algorithms, Final Report on the DFG Special Joint Initiative, volume 594 of Lecture Notes in Computer Science, pages 233–249. Springer, 1992. doi:10.1007/3-540-55488-2_30.