---
title: Approximate Closest Pair Algorithms
url: https://www.emergentmind.com/topics/approximate-closest-pair-cp
type: topic
---

# Approximate Closest Pair Algorithms

Approximate Closest Pair (CP) is the family of problems in which one seeks a pair whose distance is within a prescribed multiplicative factor of the minimum inter-point distance, rather than the exact optimum. The formulation appears in monochromatic, bichromatic, colored, query, and stochastic settings; representative versions include \((1+\varepsilon)\)-approximate Bichromatic Closest Pair, \(c\)-approximate Closest Pair queries, color distance oracles, and \((1+\varepsilon)\)-approximation of the expected closest-pair distance in uncertain tree metrics [1803.00904, 2107.05537, 2507.04578, 1612.04890]. Approximate CP is central precisely where exact high-dimensional CP becomes expensive, yet the research landscape is uneven: some models admit fast approximate algorithms, some exhibit exact-versus-approximate separations, and others carry strong conditional lower bounds even for approximation [1605.08107, 2507.04578].

## 1. Formal problem variants

In the classical monochromatic setting, CP asks for
\[
\min_{p\neq q\in P} d(p,q).
\]
A multiplicative approximation returns a pair \((p,q)\) whose distance is at most a factor \(1+\varepsilon\) or \(c>1\) above that minimum. In the high-dimensional Euclidean formulation used by PM-LSH, if \((o_1^*,o_2^*)\) is the exact closest pair with distance \(r^*\), then a \(c\)-approximate closest pair query returns a pair \((o_1,o_2)\) satisfying
\[
\|o_1,o_2\| \le c\cdot r^*
\]
[2107.05537].

A standard offline generalization is Bichromatic Closest Pair (BCP). Given two sets \(A,B\) of \(N\) vectors, the optimum value is
\[
D^*(A,B)=\min_{a\in A,\; b\in B} d(a,b),
\]
and a \((1+\varepsilon)\)-approximation outputs \((a,b)\in A\times B\) with
\[
d(a,b)\le (1+\varepsilon)\cdot D^*(A,B)
\]
[1803.00904]. The literature repeatedly uses BCP as the offline or batch analogue of approximate nearest-neighbor search.

A colored formulation appears in color distance oracles. For a metric space \(\mathbf M\), a colored point set \(S\subseteq \mathbf M\), and color classes \(P(c)\), the color distance between \(c\) and \(c'\) is
\[
\delta_{c,c'} = d(P(c),P(c')) = \min_{p\in P(c),\,q\in P(c')} d(p,q),
\]
which is exactly a bicolored closest-pair distance [2507.04578]. Approximate CDO and AMCDOCH are therefore approximate colored CP data structures in the one-dimensional array metric.

A stochastic formulation replaces the fixed optimum by a random variable. In a tree metric with independent existential probabilities, the closest-pair distance of a realization \(S'\) is \(\kappa(S')\), and the central approximation target becomes the expectation
\[
\mathbf{E}[\kappa(S)] = \int_0^\infty C_{\ge \ell}(S)\, d\ell,
\]
where \(C_{\ge \ell}(S)=\Pr[\kappa(S)\ge \ell]\) is the \(\ell\)-threshold probability [1612.04890]. This is not an approximate pair-retrieval problem; it is an approximate computation of a closest-pair statistic under uncertainty.

These variants differ not only in output type but also in what approximation means. In monochromatic and bichromatic CP, the output is usually a pair. In colored and snippets-style problems, approximation is embedded in preprocessing–query tradeoffs. In stochastic settings, approximation concerns a scalar functional of the whole realization distribution rather than a witness pair.

## 2. Algorithmic paradigms

A persistent theme is that approximate CP in high dimensions is algorithmically easier than exact CP. One exact \(L_\infty\) paper states that, if one settles for approximate solutions, many efficient algorithms are known, particularly for nearest neighbor and CP under \(L_p\) norms, and that approximate algorithms are generally “easy” in high dimensions relative to exact ones: often near-linear or \(n^{1+o(1)}\) time for a fixed approximation factor in various models [1605.08107]. The same paper explicitly positions LSH-based methods and Johnson–Lindenstrauss dimensionality reduction as contextual prior work for approximation rather than as part of its exact contribution.

PM-LSH is a representative high-dimensional Euclidean framework that makes this general picture concrete. It projects each point \(o\in\mathbb{R}^d\) to
\[
o'=[h_1^*(o),\dots,h_m^*(o)],\qquad h^*(o)=\vec a\cdot \vec o,
\]
indexes the projected points in a PM-tree, and uses the fact that
\[
\frac{r'^2}{r^2}\sim \chi^2(m)
\]
to build confidence intervals connecting projected and original distances [2107.05537]. Its closest-pair component first defines a branch-and-bound search over PM-tree node pairs using a lower bound \(\textsf{Mindist}(e_1,e_2)\), but the practical algorithm is a radius-filtering method: it derives an upper bound \(ub\) on the current \(k\)-th smallest original distance, sets a projected threshold \(t\cdot ub\), and explores only nodes whose radius is below
\[
R=\gamma\cdot t\cdot ub.
\]
The candidate cap is
\[
T=\alpha_2\,\frac{n(n-1)}{2}+k,
\]
and the stated complexity is \(O(\beta n^2)\) with \(\beta\ll 1\) in practice [2107.05537]. The framework is explicitly tunable: larger \(T\), larger \(\gamma\), or smaller \(\alpha_2\) improve recall at higher cost.

MSPP uses a different approximation template for Euclidean distance and Pearson correlation. Each attribute is clustered into \(k\) one-dimensional clusters by \(k\)-means++, then one-hot encoded, so every original point becomes a binary vector in \(\{0,1\}^{nk}\). The algorithm repeatedly samples \(c\) random encoded coordinates, hashes points by those sampled bits, computes full Hamming distance only for colliding pairs, and keeps the top \(r\) candidates in a priority queue. In a second pass it recomputes the original Euclidean distance or Pearson correlation only for those candidates and outputs the top \(s\) pairs [2007.16111]. Its analysis uses the collision estimate
\[
\Pr[\text{hash collision in one iteration}] = \frac{\binom{q_1k}{q'}}{\binom{nk}{q'}} \approx \left(\frac{q_1}{n}\right)^{q'},
\]
and shows that
\[
z \ge \alpha\left(\frac{n}{q_1}\right)^{q'}\log n
\]
iterations suffice to capture a pair that agrees on \(q_1\) attributes with probability at least \(1-n^{-\alpha}\) [2007.16111]. MSPP therefore approximates CP by first preserving coarse local agreement under discretization and then amplifying discovery probability through repeated random hashing.

The algorithmic landscape is therefore heterogeneous. One line, represented by PM-LSH, treats approximate CP as a projected metric-search problem with explicit probabilistic calibration. Another, represented by MSPP, treats it as large-scale similar-pairs mining through data-dependent discretization and repeated hash collisions. Both lines depart from low-dimensional geometric CP algorithms and target the regimes in which exact all-pairs distance evaluation is operationally infeasible.

## 3. Fine-grained complexity and hardness

Approximate CP is not uniformly easy. Strong conditional lower bounds are known for several variants. For BCP in Euclidean, Manhattan, Hamming, and edit distance, the main hardness result states that, unless SETH is false, for every \(\delta>0\) there exists a constant \(\varepsilon>0\) such that computing a \((1+\varepsilon)\)-approximation requires \(\Omega(N^{2-\delta})\) time; for Euclidean, Manhattan, and Hamming this holds in dimension \(d=O(\log N)\), and for edit distance in \(d=O(\log N\log\log N)\) [1803.00904]. The same paper derives an ANN corollary: assuming SETH, for every constants \(\delta,c>0\) there exists \(\varepsilon=\varepsilon(\delta,c)\) such that no algorithm can preprocess \(N\) vectors in \(O(N^c)\) time and answer \((1+\varepsilon)\)-ANN queries in \(O(N^{1-\delta})\) time [1803.00904].

For monochromatic CP, a separate SETH-based result shows that for every \(\varepsilon>0\) there exist constants \(\delta(\varepsilon)>0\) and \(c(\varepsilon)>1\) such that no algorithm running in time \(O(n^{1.5-\varepsilon})\) can solve \((1+\delta(\varepsilon))\)-CP in the \(\ell_p\)-metric when the dimension satisfies
\[
d \ge c(\varepsilon)\log n
\]
[1812.00901]. The same work also establishes exact CP hardness in dimensions \(d=(\log n)^{\Omega_\varepsilon(1)}\), showing that medium-dimensional approximation lower bounds and medium-dimensional exact lower bounds occupy distinct exponent regimes.

Metric dependence is sharp. For \(p>2\), it is OVH-hard to obtain an \(n^{2-\varepsilon}\)-time \((1+\gamma)\)-approximation for CP in \(d=\omega(\log n)\), and for \(L^\infty\) it is OVH-hard to obtain an \(n^{2-\varepsilon}\)-time \((2-o(1))\)-approximation [1608.03245]. By contrast, in Euclidean space the same paper stresses that its polar-pair reduction does not yield comparable hardness because biclique representations in \(L^2\) require much higher dimension [1608.03245]. This suggests that approximation hardness is substantially more metric-sensitive than the formal definitions alone might imply.

A different kind of separation arises in one-dimensional colored data structures. For exact CDO on points in an array, preprocessing \(\tilde O(n^a)\) and query time \(\tilde O(n^b)\) must satisfy
\[
a+b\ge 2
\]
under the Strong-APSP hypothesis, while for \((1+\varepsilon)\)-approximate CDO the FMM-based upper bound is
\[
a+\frac{2}{\omega-1}b=2 \quad\text{for } 0\le b\le \frac{\omega-1}{\omega+1},
\]
and
\[
\frac{2}{\omega-1}a+b=\frac{\omega+1}{\omega-1}
\quad\text{for } \frac{\omega-1}{\omega+1}\le b\le 1.
\]
When \(\omega=2\), this becomes
\[
a+2b=2 \quad\text{if } 0\le b\le \tfrac13,\qquad
2a+b=3 \quad\text{if } \tfrac13\le b\le 1,
\]
which lies strictly below the exact barrier \(a+b=2\) for part of the tradeoff curve [2507.04578]. In that model, the exact version is strictly harder than the approximate version.

Exact-versus-approximate asymmetry also appears in reductions. A paper comparing closest, furthest, and orthogonal pairs states explicitly that its conditional lower bounds only hold for exact solutions and that the reductions from OV to closest/furthest pair no longer work if one only has \((1+\varepsilon)\)-approximations [1709.05282]. This is a useful caution: approximation can evade exact fine-grained barriers, but only in some models, and not in the settings covered by the lower bounds above.

## 4. Colored, query, and oracle formulations

Approximate CP often appears not as a single optimization problem but as a query problem over structured families of subsets. The cleanest current example is the one-dimensional array metric, where a color distance oracle preprocesses \(n\) colored points so that a query on colors \(c,c'\) returns an approximation to
\[
\delta_{c,c'} = d(P(c),P(c')).
\]
This is a static approximate colored closest-pair data structure [2507.04578].

The main ACDO construction is a heavy-light decomposition. A color \(c\) is heavy if \(|P(c)|\ge \tau\); otherwise it is light. For every color, the structure stores a one-dimensional nearest-neighbor data structure \(\text{NNS}_c\). For heavy colors it additionally precomputes an approximate matrix \(E^*\) of all-heavy color distances. Heavy-heavy queries become \(O(1)\) lookups in \(E^*\), while if one queried color is light, the answer is computed exactly as
\[
\delta_{c,c'} = \min_{p\in P(c)} d(p,P(c'))
\]
using at most \(\tau\) nearest-neighbor probes [2507.04578]. The expensive part is building \(E^*\), which is done by partitioning the line into blocks of length \(W\), building Boolean matrices \(A\) and \(B^{(\ell)}\) across geometric scales \((1+\varepsilon)^\ell W\), and multiplying them. The resulting preprocessing–query tradeoff is FMM-governed rather than purely combinatorial.

The same paper extends the construction to multi-colored points with a laminar color hierarchy, AMCDOCH, and then to the snippets problem on texts via the Kopelowitz–Krauthgamer reduction. Snippets preprocesses a text \(T\) so that, for patterns \(P_1,P_2\), one can approximate the distance between closest occurrences. The resulting query time is
\[
\tilde O(|P_1|+|P_2|+|T|^b)
\]
after preprocessing time \(\tilde O(|T|^a)\), with the same tradeoff curve as ACDO [2507.04578]. In effect, approximate CP, approximate colored CP, and approximate closest-occurrence search in strings become equivalent under linear-time reductions in this one-dimensional regime.

| Problem | Model | Representative guarantee |
|---|---|---|
| ACDO | 1D array, colored points | \(a+\frac{2}{\omega-1}b=2\) or \(\frac{2}{\omega-1}a+b=\frac{\omega+1}{\omega-1}\) [2507.04578] |
| AMCDOCH | 1D array, hierarchical colors | Same preprocessing–query tradeoff as ACDO [2507.04578] |
| Snippets | Text \(T\), query patterns \(P_1,P_2\) | \((1+\varepsilon)\)-approximate closest-occurrence distance in \(\tilde O(|P_1|+|P_2|+|T|^b)\) [2507.04578] |

These oracle-style formulations matter because they expose approximation as a query-complexity resource rather than only as an optimization relaxation. They also provide one of the clearest exact-versus-approximate separations presently known for CP-type tasks.

## 5. Metric-dependent and stochastic variants

Approximate CP behaves differently across metric classes. In tree spaces with existential uncertainty, the problem becomes probabilistic rather than purely geometric. Given a stochastic point set \(S\) on a weighted tree, the threshold probability
\[
C_{\ge \ell}(S)=\Pr[\kappa(S)\ge \ell]
\]
can be computed exactly in
\[
O(t+n\log n+\min\{tn,n^2\})
\]
time for any fixed threshold \(\ell\), where \(t\) is the number of tree vertices after preprocessing [1612.04890]. The same work gives an exact algorithm for \(\mathbf{E}[\kappa(S)]\) in
\[
O(t+\min\{tn^3,n^4\})
\]
time and a \((1+\varepsilon)\)-approximation in
\[
O(t+\varepsilon^{-1}\min\{tn^2,n^3\})
\]
time, using the fact that the expectation can be approximated via \(O(\varepsilon^{-1}n)\) threshold-probability queries [1612.04890]. Here approximation is over a random closest-pair distance, not over a fixed witness pair.

At the opposite end of the spectrum, in constant doubling dimension exact CP is already easy. A randomized divide-and-conquer algorithm computes the exact closest-pair distance in \(O(N\log N)\) expected time in doubling metrics [2004.05883]. This suggests that, in sufficiently low-dimensional metric structure, approximation is not needed for asymptotic speed; its main value then lies in simplification, robustness, or engineering.

Range-query versions introduce another axis. In fixed-dimensional Euclidean space, exact range closest-pair data structures are known for orthogonal boxes, simplices, halfspaces, and balls. For orthogonal queries in \(\mathbb{R}^d\), one result gives \(\tilde O(n)\) space, \(\tilde O(n^{3/2})\) preprocessing, and \(\tilde O(\sqrt n)\) query time [1905.01029]. The same work proves a conditional lower bound for exact orthogonal RCP in \(\mathbb{R}^3\), via reductions from set intersection and color uniqueness, implying that linear-space exact orthogonal RCP cannot beat \(\tilde\Omega(\sqrt n)\) query time under the stated conjecture [1905.01029]. A plausible implication is that approximation is the natural route to polylogarithmic-query range CP in higher dimensions, although that paper itself develops only exact structures.

High-dimensional exact \(L_\infty\) CP offers a further benchmark. One exact paper states that its contribution is not to approximation, but it emphasizes that approximate algorithms based on LSH and JL are already abundant, whereas exact high-dimensional \(L_\infty\) CP remains difficult [1605.08107]. Approximate CP is therefore best understood as metric-dependent: it ranges from unnecessary, to natural, to indispensable, depending on whether the ambient structure already admits near-linear exact algorithms.

## 6. Practical systems and empirical profiles

Practical approximate CP has developed into a systems topic as well as an algorithmic one. PM-LSH is an in-memory framework for high-dimensional approximate NN and CP search in Euclidean space. Its experimental closest-pair results are reported as \((\text{time}, \text{overall ratio}, \text{recall})\). On the Audio dataset it achieves
\[
(0.83\text{s},\, 1.002,\, 0.964),
\]
compared with NLJ at \(388.0\)s and exact ratio \(1.000\) [2107.05537]. On MNIST it reports
\[
(33.6\text{s},\, 1.004,\, 0.937),
\]
while NLJ takes \(1900.4\)s [2107.05537]. On larger datasets such as GIST, PM-LSH reports
\[
(81.8\text{s},\, 1.101,\, 0.772),
\]
again substantially below exact nested-loop time [2107.05537]. The key point is not merely speed but a tunable balance among projected candidate count, radius thresholding, and exact verification.

MSPP targets large Euclidean or Pearson-similarity datasets stored on disk. On the real gene-expression datasets D1.1–D1.6, its reported A-Rank is \(1\), meaning that across the reported runs the best returned pair is the true closest pair [2007.16111]. In time-series experiments with up to \(30{,}000\) points of length \(1000\), it also reports A-Rank \(1\), with Top-50 and Top-100 accuracy remaining near \(1.00\) for smaller instances and degrading gradually as the datasets grow [2007.16111]. Against motif-mining baselines, the same paper reports substantial speedups; for example, with \(1\) million points and \(512\) dimensions, JUMP takes \(71.67\) minutes while MSPP takes \(6.74\) minutes [2007.16111].

These systems expose a persistent engineering pattern. First, approximation is often implemented as candidate-generation plus exact re-ranking. Second, the practical quality metric is frequently recall or rank rather than a worst-case multiplicative bound on distance. Third, the most effective methods are highly model-specific: PM-LSH exploits projected Euclidean geometry and PM-trees, while MSPP exploits per-attribute discretization and repeated hash collisions.

Approximate CP therefore occupies two distinct but connected roles. In theory, it is a family of optimization and query problems with nuanced exact-versus-approximate separations and strong lower bounds in several regimes. In practice, it is a high-dimensional systems problem in which randomized filtering, candidate compression, and selective exact verification are the dominant design principles.

Source: https://www.emergentmind.com/topics/approximate-closest-pair-cp