On Locality-Sensitive Orderings and their Applications

For any constant $d$ and parameter $\varepsilon>0$, we show the existence of (roughly) $1/\varepsilon^d$ orderings on the unit cube $[0,1)^d$, such that any two points $p,q\in [0,1)^d$ that are close together under the Euclidean metric are"close together"in one of these linear orderings in the following sense: the only points that could lie between $p$ and $q$ in the ordering are points with Euclidean distance at most $\varepsilon\| p - q \|$ from $p$ or $q$. These orderings are extensions of the $\mathcal{Z}$-order, and they can be efficiently computed. Functionally, the orderings can be thought of as a replacement to quadtrees and related structures (like well-separated pair decompositions). We use such orderings to obtain surprisingly simple algorithms for a number of basic problems in low-dimensional computational geometry, including (i) dynamic approximate bichromatic closest pair, (ii) dynamic spanners, (iii) dynamic approximate minimum spanning trees, (iv) static and dynamic fault-tolerant spanners, and (v) approximate nearest neighbor search.


Preface
In this paper, we describe a technique that leads to new, simpler algorithms for a number of fundamental proximity problems in low-dimensional Euclidean spaces.
Given data, having an ordering over it is quite useful-it enables one to sort it, store it, and search it efficiently, among other things. Such an order is less natural for points in the plane (or in higher dimensions). One way to impose such orders is by using bijective mappings from the plane to the line (which has a natural order, and thus endows the plane with an order). Such mappings, known as space-filling curves, were discovered in 1890 by Peano [Pea90]. (See also the book by Sagan [Sag94] for more information on space-filling curves.) For computational purposes, the Z-order, a somewhat inferior space-filling curve, is the easiest to implement as it is easily computed by interleaving the bits of the x and y coordinates.
A natural property one desires in an ordering of the plane is that it preserves locality-points that are close together geometrically remain close in the resulting ordering. Unfortunately, no mapping/ordering can have this property universally, as the topology of the line and the plane are fundamentally different. Nevertheless, the Z-order already has some nice locality properties-it maps certain squares to intervals on the real line, and these squares forms grids that cover the unit square. Furthermore, these grids are universal, in the sense that there is a grid for any desired resolution.
To get better locality properties, one has to use more orders. It is known that if one uses three orders in the plane (which is the result of shifting the plane before applying the Z-order), then for any axis parallel square C (inside the unit square), there exists a square C that contains C, such that C is only slightly bigger than C, and one of the three orders maps C to an interval. Our purpose here is to get an even stronger locality property, which requires a larger collection of orderings. Specifically, consider two points p, p ∈ [0, 1] 2 . The desired property is that there are two squares C and C , and an order σ in the collection, with the following properties: (i) p ∈ C and p ∈ C , (ii) the diameters of C and C are only an ε-fraction of the distance between p and p , (iii) C and C are mapped to two intervals on the real line by σ, and (iv) these two intervals are adjacent. Such an ordering σ with the desired properties is illustrated in Figure 1.1.
For algorithmic applications, this collection of orders needs to be small, and it needs to be easily computable. Surprisingly, we show that the desired collection of orders has size that depends only on ε, and these orders can be easily computed.
To see why having such a collection of orders is so useful, consider the problem of computing the closest pair of points in a given set of points P . Every order in the collection induces an ordering of P . Furthermore, the closest pair of points are going to be adjacent in one of these orders, and as such can be readily computed by considering all consecutive pairs of points in the ordering (the number of such pairs is linear). Furthermore, using balanced binary search trees, it is easy to maintain each ordered set under insertions and deletions. Therefore, one can maintain the closest pair of points by storing P in such a data structure for each of the orderings. As a result, a dynamic problem that might seem in advance somewhat challenging reduces (essentially) to the mundane task of maintaining ordered sets under insertions and deletions.

Introduction
Quadtrees and Z-order. Consider a point set P ⊆ [0, 1) 2 , its quadtree, and a depth-first search (DFS) traversal of this quadtree. One can order the points of P according to this traversal, resulting in some ordering ≺ of the underlying set [0, 1) 2 . The relation ≺ is the ordering along some space filling mapping.
One particular ordering of interest is the Z-order . Conceptually speaking, the Z-order can be thought of as a DFS of the quadtree over [0, 1) 2 , where the children of each node in the quadtree are always visited in the same pre-defined order (see Figure 1.2). The Z-order is a total ordering over the points in [0, 1) 2 , and can be formally defined by a bijection z from the unit interval [0, 1) to the unit square [0, 1) 2 . Given a real number α ∈ [0, 1), with the binary expansion α = 0.
, the Z-order mapping of α is the point z(α) = (0.x 2 x 4 x 6 . . . , 0.x 1 x 3 x 5 . . .). We note that the Z-order mapping z is not continuous. Nevertheless, the Z-order mapping has the advantage of being easy to define. In particular, computing the Zorder or its inverse is quite easy, if one is allowed bitwise-logical operations-in particular, the ability to compute compressed quadtrees efficiently is possible only if such operations are available [Har11]. The approach extends to higher constant dimensions.
The idea of using the Z-order can be traced back to the work of Morton [Mor66], and it is widely used in databases and seems to improve performance in practice [KF93]. Once comparison by Z-order is available, building a compressed quadtree is no more than storing the points according to the Z-order, and this yields simple data structures for various problems. For example, Liao et al. [LLL01] and Chan [Cha02,Cha06,Cha08] applied the Z-order to obtain simple efficient algorithms for approximate nearest neighbor search and related problems.
Shifting. The Z-order (and quadtrees) does not preserve distance. That is, two points that are far away might be mapped to two close-together points, and vice versa. This problem is even apparent when using a grid, where points that are close together get separated into different grid cells. One way to get around this problem is to shift the grid (deterministically or randomly) [HM85]. The same approach works for quadtrees-one can shift the quadtree constructed for a point set several times such that for any pair of points in the quadtree, there will be a shift where the two points are in a cell of diameter that is O d (1) times their distance. (Throughout, we use the O d notation to hide constants that depend on d. Similarly, O ε hides dependencies on ε.) Improving an earlier work by Bern [Ber93], Chan [Cha98] showed that 2 d/2 + 1 deterministic shifts are enough in d dimensions (a proof is reproduced in Appendix A.2). A somewhat similar shifting scheme was also suggested by Feige and Krauthgamer [FK97]. Random shifting of quadtrees underlines, for example, the approximation algorithm by Arora for Euclidean TSP [Aro98].
By combining Z-order with shifting, both Chan [Cha02] and Liao et al. [LLL01] observed an extremely simple data structure for O d (1)-approximate nearest neighbor search in constant dimensions: just store the points in Z-order for each of the 2 d/2 + 1 shifts; given a query point q, find the successor and predecessor of q in the Zorder by binary search for each of the shifts, and return the closest point found. The data structure can be easily made dynamic to support insertions and deletions of points, and can also be adapted to find O d (1)-approximate bichromatic closest pairs.
For approximate nearest neighbor (ANN) search, the O d (1) approximation factor can be reduced to 1 + ε for any fixed ε > 0, though the query algorithm becomes more involved [Cha02] and unfortunately cannot be adapted to compute (1 + ε)-approximate bichromatic closest pairs dynamically. (In the monochromatic case, however, the approach can be adapted to find exact closest pairs, by considering O d (1) successors and predecessors of each point [Cha02].) For other proximity-related problems such as spanners and approximate minimum spanning trees (MST), this approach does not seem to work as well: for example, the static algorithms in [Cha08], which use the Z-order, still requires explicit constructions of compressed quadtrees and are not easily dynamizable.
Main new technique: Locality-sensitive orderings. For any given ε > 0, we show that there is a family of O d ((1/ε d ) log(1/ε)) orderings of [0, 1) d with the following property: For any p, q ∈ [0, 1) d , there is an ordering in the family such that all points lying between p and q in this ordering are within distance at most ε p − q from either p or q (where · is the standard Euclidean norm). The order between two points can be determined efficiently using some bitwise-logical operations. See Theorem 3.10. We refer to these as locality-sensitive orderings. They generalize the previous construction of 2 d/2 + 1 shifted copies of the Z-order, which guarantees the stated property only for a large specific constant (equivalent to setting ε ≈ d 3/2 ). The new refined property ensures, for example, that a (1 + ε)-approximate nearest neighbor of a point q can be found among the immediate predecessors and successors of q in these orderings.
Applications. Locality-sensitive orderings immediately lead to simple algorithms for a number of problems, as listed below. Many of these results are significant simplification of previous work; some of the results are new.
(A) Approximate bichromatic closest pair. Theorem 4.2 presents a data structure that maintains a (1 + ε)approximate closest bichromatic pair for two sets of points in R d , with an update time of O d,ε (log n), for any fixed ε > 0 (the hidden factors depending on ε are proportional to (1/ε d ) log 2 (1/ε)). Previously, a general technique of Eppstein [Epp95] can be applied in conjunction with a dynamic data structure for ANN, but the amortized update time increases by two log n factors.
(B) Dynamic spanners. For a parameter t ≥ 1 and a set of points P in R d , a graph G = (P, E) is a tspanner for P if for all p, q ∈ P , there is a p-q path in G of length at most t p − q . Static algorithms for spanners have been extensively studied in computational geometry. The dynamic problem appears tougher, and has also received much attention (see Table 2.1). We obtain a very simple data structure for maintaining dynamic (1 + ε)-spanners in Euclidean space with an update (insertion and deletion) time of O d,ε (log n) and having O d,ε (n) edges in total, for any fixed ε > 0. See Theorem 4.4. Although Gottlieb and Roditty [GR08b] have previously obtained the same update time O d,ε (log n), their method requires much more intricate details. (Note that Gottlieb and Roditty's method more generally applies to spaces with bounded doubling dimension, but no simpler methods have been reported in the Euclidean setting.) (C) Dynamic approximate minimum spanning trees. As is well-known [CK93,Har11], a (1 + ε)-approximate Euclidean MST of a point set P can be computed from the MST of a (1 + ε)-spanner of P . In our dynamic spanner (and also Gottlieb and Roditty's method [GR08b]), each insertion/deletion of a point causes O d,ε (1) edge updates to the graph. Immediately, we thus obtain a dynamic data structure for maintaining a (1 + ε)-approximate Euclidean MST, with update time (ignoring dependencies on d and ε) equal to that for the dynamic graph MST problem, which is currently O(log 4 n/ log log n) with amortization [HRW15].
(D) Static and dynamic vertex-fault-tolerant spanners. For parameters k, t ≥ 1 and a set of points P in R d , a k-vertex-fault-tolerant t-spanner is a graph G which is a t-spanner and for any P ⊆ P of size at most k, the graph G \ P remains a t-spanner for P \ P . Fault-tolerant spanners have been extensively studied (see Table 2.2). Locality-sensitive orderings lead to a very simple construction for k-vertex-fault-tolerant  [Rod12] log n n 1/3 log O(1) n Gottlieb and Roditty [GR08a] log 2 n log 3 n Gottlieb and Roditty [GR08b] log n log n Theorem 4.4 log n log n unbounded n log n + k 2 n kn log n unbounded kn log n Lukovszki [Luk99a,Luk99b] kn k 2 n log d−1 n + kn log log n Czumaj and Zhao [CZ04] kn k kn log d n + k 2 n log k H. Chan et al. [CLNS15] k 2 n k 2 n log n + k 2 n Kapoor and Li [KL13]/Solomon [Sol14] kn k n log n + kn Theorem 4.6 kn k n log n + kn .
(E) Approximate nearest neighbors. Locality-sensitive orderings lead to a simple dynamic data structure for (1 + ε)-approximate nearest neighbor search with O d,ε (log n) time per update/query. While this result is not new [Cha02], we emphasize that the query algorithm is the simplest so far-it is just a binary search in the orderings maintained.
Computational models and assumptions. The model of computation we have assumed is a unit-cost real RAM, supporting standard arithmetic operations and comparisons (but no floor function), augmented with bitwise-logical operations (bitwise-exclusive-or and bitwise-and), which are commonly available in programming languages (and in reality are cheaper than some arithmetic operations like multiplication). If we assume that input coordinates are integers bounded by U and instead work in the word RAM model with (log U )-bit words (U ≥ n), then our approach can actually yield sublogarithmic query/update time. For example, we can achieve O d,ε (log log U ) expected time for dynamic approximate bichromatic closest pair, dynamic spanners, and dynamic ANN, by replacing binary search with van Emde Boas trees [vEB77]. Sublogarithmic algorithms were known before for dynamic ANN [Cha02], but ours is the first sublogarithmic result for dynamic (1 + ε)-spanners. Our results also answers the open problem of dynamic (1 + ε)-approximate bichromatic closest pair in sublogarithmic time, originally posed by Chan and Skrepetos [CS17].
Throughout, we assume (without loss of generality) that ε is a power of 2; that is, ε = 2 −E for some positive integer E.

Grids and orderings
Definition. For a set X, consider a total order (or ordering) ≺ on the elements of X. Two elements x, y ∈ X are adjacent if there is no element z ∈ X, such that x ≺ z ≺ y or y ≺ z ≺ x.
Given two elements x, y ∈ X, such that The following is well known, and goes back to a work by Walecki in the 19th century [Als08]. We include a proof in Appendix A.1 for the sake of completeness. Definition 3.2. Consider an axis-parallel cube C ⊆ R d with side length . Partitioning it uniformly into a t × t × · · · × t grid G creates the t-grid of C. The grid G is a set of t d identically sized cubes with side length /t.
By Lemma 3.1 we obtain the following result.
orderings, such that for any 1 , 2 ∈ G, there exists an order σ ∈ O(t, d) where 1 and 2 are adjacent in σ.

ε-Quadtrees
Definition 3.4. An ε-quadtree T ε is a quadtree-like structure, built on a cube with side length , where each cell is partitioned into a (1/ε)-grid. The construction then continues recursively into each grid cell of interest. As such, a node in this tree has up to 1/ε d children, and a node at level i ≥ 0 has an associated cube of side length ε i . When ε = 1/2, this is a regular quadtree.
Lemma 3.5. Let E > 0 be an integer, ε = 2 −E , and T be a regular quadtree over [0, 2) d . There are ε-quadtrees T 0 ε , . . . , T E−1 ε , such that the collection of cells at each level in T is contained in exactly one of these ε-quadtrees. Proof: observe that the collection of cells at levels j, j + E, j + 2E, . . . , of T will also be in the quadtree T j ε . Indeed, any node at level j + E in T corresponds to a cell of side length 2 −(j+ E)+1 . Now in the ( + 1)th level of quadtree T j ε , this same node will have side length Consider an ε-quadtree T ε . Every node has up to 1/ε d children. Consider any ordering σ of 1, . . . , 1/ε d . Conceptually speaking, this induces a DFS of T ε that always visits the children of a node in the order specified by σ. This induces an ordering on the points in the cube which is the root of T ε . Indeed, for any two points, imagine storing them in an ε-quadtree-this implies that the two points are each stored in their own leaf node, which contains no other point of interest. Now, independently of what other points are stored in the quadtree, this DFS traversal would visit these two points in the same order. This can be viewed as a space filling curve (which is not continuous) which maps a cube to an interval. This is a generalization of the Z-order. In particular, given a point set stored in T ε , and given σ, one can conceptually order the points according to this DFS traversal, resulting in 1-dimensional ordering of the points. We denote the resulting ordering by (T ε , σ).
In Section 3.3, we show that given (T ε , σ), the order of any two points in [0, 2) d can be determined efficiently, and avoids explicitly handling this DFS traversal of T ε . Alternatively, the DFS on T ε (according to σ) is implicitly defined by the total ordering (T ε , σ) of points in [0, 2) d .
Definition 3.6. Let Π be the set of all orderings of [0, 2) d , induced by picking one of the lg(1/ε) trees of Lemma 3.5, together with an ordering σ ∈ O(1/ε, d), as defined by Lemma 3.1. Each ordering in Π is an ε-ordering .
Suppose there are two points which lie in a quadtree cell that has diameter close to their distance. Formally, consider two points p, q ∈ [0, 1) d , a parameter ε > 0, such that p, q are both contained in a cell of the regular quadtree T with diam( ) ≤ 2 p − q . Then, there is an ε-quadtree T ε that has as a node, and let p and q be the two children of in T ε , containing p and q respectively. Furthermore, there is an ordering σ ∈ O(1/ε, d), such that p and q are adjacent. As such, the cube p (resp., q ) corresponds to an interval [x, x ) (resp., [x , x )) in the ordering (T ε , σ), and these two intervals are adjacent. In particular, this implies that all points lying between p and q in σ have distance at most 2ε p − q from p or q.
If the above statement were true for all pairs of points, then this would imply the main result (Theorem 3.10). However, consider the case when there are two points close together, but no appropriately sized quadtree cell contains both p and q. In other words, two points that are close together might get separated by nodes that are much bigger in the quadtree, and this would not provide the guarantee of the main result. However, this issue can be resolved using shifting. We need the following result of Chan [Cha98, Lemma 3.3]-a proof is provided in Appendix A.2.

Comparing two points according to an ε-ordering
We now show how to efficiently compare two points in P according to a given ε-ordering σ with a shift v i . The shift can be added to the two points directly, and as such we can focus on comparing two points according to σ.
First, we show how to compare the msb of two numbers using only bitwise-exclusive-or and bitwise-and operations. We remark that Observation 3.8 (A) is from Chan [Cha02].  Proof Assume that a < b and a < a ⊕ b. Since a < b, it must be that msb(a) ≥ msb(b). Observe that if msb(a) = msb(b), then a ⊕ b < a, which is impossible. It follows that msb(a) > msb(b), as desired. Lemma 3.9. Let p = (p 1 , . . . , p d ) and q = (q 1 , . . . , q d ) be two distinct points in P ⊆ [0, 2) d and σ ∈ Π be an ε-ordering over the cells of some ε-quadtree T ε storing P . Then one can determine if p ≺ σ q using O(d log(1/ε)) bitwise-logical operations.
Proof: Recall ε is a power of two and E = lg(1/ε). In order to compare p and q, for i = 1, . . . , d, compute a i = p i ⊕ q i . Find an index i such that msb(a i ) ≤ msb(a i ) for all i. Such an index can be computed with O(d) msb comparisons (using Observation 3.8 (A)). Given p i and q i , we next determine the place in which p i and q i first differ in their binary representation. Note that because ε is a power of two, each digit in the base 1/ε expansion of p i corresponds to a block of E bits in the binary expansion of p i . Suppose that p i and q i first differ inside the hth block at an index j ∈ {1, . . . E}.
The algorithm now locates this index j. To do so, for j = 1, . . . , E, let b j = 2 E−j /(2 E − 1) ∈ (0, 1] be the number whose binary expansion has a 1 in positions j, j + E, j + 2E, . . ., and 0 everywhere else. For j = 1, . . . , E, compute b j ∧ a i and check if msb(a i ) = msb(b j ∧ a i ) (using Observation 3.8 (B)). When the algorithm finds such an index j obeying this equality, it exits the loop. We know that p i and q i first differ in the jth position inside the hth block (the value of h is never explicitly computed).
It remains to extract the E bits from the hth block in each coordinate p 1 , . . . , p d .
is the indicator function). By repeating a similar process for all q 1 , . . . , q d , we obtain the coordinates of the cells in which p and q differ. We can then consult σ to determine whether or not p ≺ σ q. This implies that p and q can be compared using O(d log(1/ε)) operations by Observation 3.8.

Remark.
In the word RAM model for integer input, the extra log(1/ε) factor in the above time bound can be eliminated: msb can be explicitly computed in O(1) time by a complicated algorithm of Fredman and Willard [FW93]; this allows us to directly jump to the right block of each coordinate and extract the relevant bits. (Furthermore, assembly operations performing such computations are nowadays available on most CPUs.)
Proof: Let Π + be the set of all orderings defined by picking an ordering from Π, as defined by Definition 3.6 using the parameter ε, together with a shift from Lemma 3.7.
Consider any two points p, q ∈ [0, 1) d . By Lemma 3.7 there is a shift for which the two points fall into a quadtree cell with side length at most 2(D + 1) p − q . Next, there is an ε-quadtree T ε that contains , and the two children that correspond to two cells p and q with side length at most 2(D +1)ε p − q , which readily implies that the diameter of these cells is at most 2(D + 1) √ dε p − q . Furthermore, there is an ε-ordering in Π such that all the points of p are adjacent to all the points of q in this ordering. This implies the desired claim, after adjusting ε by a factor of 2(D + 1) √ d (and rounding to a power of 2).
From now on, we refer to the set of orderings Π + in the above Theorem as locality-sensitive orderings. We remark that by the readjustment of ε in the final step of the proof, the number of locality-sensitive orderings when including the factors involving d is O(d 3/2 ) d · (1/ε d ) log(1/ε).

Discussion
Connection to locality-sensitive hashing. Let P be a set of n points in Hamming space {0, 1} d . Consider the decision version of the (1 + ε)-approximate nearest neighbor problem. Specifically, for a pre-specified radius r and any given query point q, we would like to efficiently decide whether or not there exists a point p ∈ P such that q − p 1 ≤ (1 + ε)r or conclude that all points in P are at least distance r from q. The locality-sensitive hashing (LSH) technique [IM98] implies the existence of a data structure supporting this type of decision query in time O(dn 1/(1+ε) log n) time (which is correct with high probability) and using total space O(dn 1+1/(1+ε) log n). Similar results also hold in the Euclidean setting.
At a high level, LSH works as follows. Start by choosing k := k(ε, r, n) indices in [d] at random (with replacement). Let R denote the resulting multiset of coordinates. For each point p ∈ P , let p R be the projection p onto these coordinates of R. We can group the points of P into buckets, where each bucket contains points with the same projection. Given a query point q, we check if any of the points in the same bucket as q is at distance at most (1 + ε)r from q. This construction can also be repeated a sufficient number of times in order to guarantee success with high probability.
The idea of bucketing can also be viewed as an implicit ordering on the randomly projected point set by ordering points lexicographically according to the k coordinates. In this sense, the query algorithm can be viewed as locating q within each of the orderings, and comparing q to similar points nearby in each ordering. From this perspective, every locality-sensitive ordering can be viewed as an LSH scheme. Indeed, for a given query point q, the approximate nearest neighbor to q can be found by inspecting the elements adjacent to q in each of the locality-sensitive orderings and returning the closest point to q found (see Theorem 4.7).
Of course, the main difference between the two schemes is that for every fixed ε, the number of "orderings" in an LSH scheme is polynomial in both d and n. While for locality-sensitive orderings, the number of orderings remains exponential in d. This trade-off is to be expected, as locality-sensitive orderings guarantee a much stronger property than that of an LSH scheme.
Extension of locality-sensitive orderings to other norms in Euclidean space. The L p -norm, for p ≥ 1, of a vector x ∈ R d is defined as x p = (|x 1 | p + · · · + |x n | p ) 1/p . The L ∞ -norm, or maximum norm, is defined as The result of Theorem 3.10 also holds for any L p -norm. The key change that is needed is in the proof of Lemma 3.7: For any two points s, t ∈ [0, 1) d , there exists a shift v such that s + v and t + v are contained in a quadtree cell of side length at most 2(D + 1) s − t p . This extension follows easily from the proof of the Lemma (see Appendix A.2). Theorem 3.10 then follows by adjusting ε by a factor of 2(D + 1)d 1/p in the last step, implying that the number of orderings will be O(d 1+1/p ) d (1/ε d ) log(1/ε). (For the L ∞ -norm, ε only needs to be adjusted by a factor of 2(D + 1).) Extension of locality-sensitive orderings for doubling metrics. An abstraction of low-dimensional Euclidean space, is a metric space with (low) doubling dimension. Formally, a metric space (M, d) has doubling dimension λ if any ball of M of radius r can be covered by at most 2 λ balls of half the radius (i.e., r/2). It is known that R d has doubling dimension O(d) [Ver05]. We point out that locality-sensitive orderings still exist in this case, but they are less constructive in nature, since one needs to be provided with all the points of interest in advance.
For a point set P ⊆ M, the analogue of a quadtree for a metric space is a net tree [HM06]. A net tree can be constructed as follows (the construction algorithm described here is somewhat imprecise): The root node corresponds to the point set P ⊆ M. Compute a randomized partition of P of diameter 1/2 (assume P has diameter one), and for each cluster in the partition, create an associated node and hang it on the root. The tree is computed recursively in this manner, at each level i computing a random partition of diameter 2 −i . The leaves of the tree are points of P .
As with quadtrees, it is possible during this randomized construction for two nearby points to be placed in different clusters and be separated further down the tree. If = d(p, q) for two points p, q ∈ P , then the probability that p and q lie in different clusters of diameter r = 2 −i in the randomized partition is at most O(( /r) log n) [FRT04]. In particular, for r ≈ 1/( log n), the probability that p and q are separated is at most a constant. If we want this property to hold with high probability for all pairs of points, one needs to construct O(log n) (randomly constructed) net trees of P . (This corresponds to randomly shifting a quadtree O(log n) times in the Euclidean setting.) Given such a net tree T , each node has I = 2 O(λ) children. We can arbitrarily and explicitly number the children of each node by a distinct label from I . One can define an ordering of such a tree as we did in the Euclidean case, except that the gap (in diameter) between a node and its children is O(ε/ log n) instead of ε. Repeating our scheme in the Euclidean case, this implies that one would expect to require (ε −1 log n) O(λ) orderings of P . This requires having all the points of P in advance, which is a strong assumption for a dynamic data structure (as in some of the applications below). For example, Gottlieb and Roditty [GR08b] show how to maintain dynamic spanners in a doubling metric, but only assuming that after a point has been deleted from P , the distance between the deleted point and a point currently in P can still be computed in constant time.

Bichromatic closest pair
Given an ordering σ ∈ Π + , and two finite sets of points R, B in R d , let Z = Z(σ, R, B) be the set of all pairs of points in R × B that are adjacent in the ordering of R ∪ B according to σ. Observe that inserting or deleting a single point from these two sets changes the contents of Z by a constant number of pairs. Furthermore, a point participates in at most two pairs. Lemma 4.1. Let R and B be two sets of points in [0, 1) d , and let ε ∈ (0, 1) be a parameter. Let σ ∈ Π + be a locality-sensitive ordering (see Theorem 3.10). Then, one can maintain the set Z = Z(σ, R, B) under insertions and deletions to R and B. In addition, one can maintain the closest pair in Z (under the Euclidean metric). Each update takes O(d log n log(1/ε)) time, where n is the total size of R and B during the update operation.
Proof: Maintain two balanced binary search trees T R and T B storing the points in R and B, respectively, according to the order σ. Insertion, deletion, predecessor query and successor query can be implemented in O(d log(1/ε) log n) time (since any query requires O(log n) comparisons each costing O(d log(1/ε)) time by Lemma 3.9). We also maintain a min-heap of the pairs in Z sorted according to the Euclidean distance. The minimum is the desired closest pair. Notice that a single point can participate in at most two pairs in Z.
We now explain how to handle updates. Given a newly inserted point r (say a red point that belongs to R), we compute the (potential) pairs it participates in, by computing its successor r in R, and its successor b in B. If r ≺ σ b ≺ σ r then the new pair rb should be added to Z. The pair before r in the ordering that might use r is computed in a similar fashion. In addition, we recompute the predecessor and successor of r in R, and we recompute the pairs they might participate in (deleting potentially old pairs that are no longer valid).
Deletion is handled in a similar fashion-all points included in pairs with the deleted point recompute their pairs. In addition, the successor and predecessor (of the same color) need to recompute their pairs. This all requires a constant number of queries in the two trees, and thus takes the running time as stated.
Theorem 4.2. Let R and B be two sets of points in [0, 1) d , and let ε ∈ (0, 1/2] be a parameter. Then one can maintain a (1 + ε)-approximation to the bichromatic closest pair in R × B under updates (i.e., insertions and deletions) in O d (log n log 2 (1/ε)/ε d ) time per operation, where n is the total number of points in the two sets. The data structure uses O d (n log(1/ε)/ε d ) space, and at all times maintains a pair of points r ∈ R, b ∈ B, such that Proof: We maintain the data structure of Lemma 4.1 for all the locality-sensitive orderings of Theorem 3.10. All the good pairs for these data structures can be maintained together in one global min-heap. The claim is that the minimum length pair in this heap is the desired approximation.
To see that, consider the bichromatic closest pair r ∈ R and b ∈ B. By Theorem 3.10 there is a localitysensitive ordering σ, such that the interval I in the ordering between r and b contains points that are in distance at most = ε r − b from either r or b. In particular, let P r (resp., P b ) be all the points in I in distance at most from r (resp., b). Observe that P r ⊆ R, as otherwise, there would be a bichromatic pair in P R , and since the diameter of this set is at most , this would imply that (r, b) is not the closest bichromatic pair-a contradiction. Similarly, P b ⊆ B. As such, there must be two points b ∈ B and r ∈ R, that are consecutive in σ, and this is one of the pairs considered by the algorithm (as it is stored in the min-heap). In particular, by the triangle inequality, we have The theorem follows after adjusting ε by a factor of 2.
Remark. In the word RAM model, for integer input in {1, . . . , U } d , the update time can be improved to O d ((log log U ) log 2 (1/ε)/ε d ) expected, by using van Emde Boas trees [vEB77] in place of the binary search trees (and the min-heaps as well). With standard word operations, we may not be able to explicitly map each point to an integer in one dimension following each locality-sensitive ordering, but we can still simulate van Emde Boas trees on the input as if the mapping has been applied. Each recursive call in the van Emde Boas recursion focuses on a specific block of bits of each input coordinate value (after shifting); we can extract these blocks, and perform the needed hashing operations on the concatenation of these blocks over the d coordinates of each point.

Dynamic spanners
Definition 4.3. For a set of n points P in R d and a parameter t ≥ 1, a t-spanner of P is an undirected graph G = (P, E) such that for all p, q ∈ P , where d G (p, q) is the length of the shortest path from p to q in G using the edge set E.
Using a small modification of the results in the previous section, we easily obtain a dynamic (1 + ε)-spanner. Note that there is nothing special about how the data structure in Theorem 4.2 deals with the bichromatic point set. If the point set is monochromatic, modifying the data structure in Lemma 4.1 to account for the closest monochromatic pair of points leads to a data structure with the same bounds and maintains the (1 + ε)approximate closest pair.
The construction of the spanner is very simple: Given P and ε ∈ (0, 1), maintain orderings of the points specified by Π + (see Theorem 3.10). For each σ ∈ Π + , let E σ be the edge set consisting of edges connecting two consecutive points according to σ, with weight equal to their Euclidean distance. Thus |E σ | = n − 1. Our spanner G = (P, E) then consists of the edge set E = σ∈Π + E σ .
Proof: The construction is described above. The same analysis as in the proof of Theorem 4.2 implies the number of edges in G and the update time.
It remains to prove that G is a spanner. By Theorem 3.10, for any pair of points s, t ∈ P , there is a locality-sensitive ordering σ ∈ Π + , such that the σ-interval [s, t) contains only points that are in distance at most ε s − t from either s or t. In particular, there must be two points in s , t ∈ P that are adjacent in σ, such that one of them, say s (resp., t ) is in distance at most ε s − t from s (resp., t). As such, the edge s t exists in the graph being maintained.
This property is already enough to imply that this graph is a (1 + cε)-spanner for a sufficiently large constant c-this follows by an induction on the distances between the points (specifically, in the above, we apply the induction hypothesis on the pairs s, s and t, t ). We omit the easy but somewhat tedious argumentsee [CK93] or [Har11, Theorem 3.12] for details. The theorem follows after adjusting ε by a factor of c.

Static and dynamic vertex-fault-tolerant spanners
Definition 4.5. For a set of n points P in R d and a parameter t ≥ 1, a k-vertex-fault-tolerant t-spanner of P , denoted by (k, t)-VFTS, is a graph G = (P, E) such that (i) G is a t-spanner (see Definition 4.3), and (ii) For any P ⊆ P of size at most k, the graph G \ P is a t-spanner for P \ P .
A (k, 1 + ε)-VFTS can be obtained by modifying the construction of the (1 + ε)-spanner in Section 4.2. Construct a set of locality-sensitive orderings Π + . For each σ ∈ Π + and each p ∈ P , connect p to its k + 1 successors and k + 1 predecessors according to σ with edge weights equal to the Euclidean distances. Thus each ordering maintains O(nk) edges and there are O(|Π + | kn) = O d (kn log(1/ε)/ε d ) edges overall. We now prove that this graph G is in fact a (k, 1 + ε)-VFTS.
The number of edges is O d (kn log(1/ε)/ε d ) and the maximum degree is bounded by O d (k log(1/ε)/ε d ).
Proof: The construction algorithm, number of edges, and maximum degree follows from the discussion above. So, consider deleting a set P ⊆ P of size at most k from G. Consider an ordering σ ∈ Π + with the points P removed. By the construction of G, all the pairs of points of P \ P that are (now) adjacent in σ remain connected by an edge in G \ P . The argument of Theorem 4.4 implies that the remaining graph is spanner. We conclude that G \ P is a (1 + ε)-spanner for P \ P .
As for the time taken to handle insertions and deletions, one simply maintains the orderings of the points using balanced search trees. After an insertion of a point to one of the orderings in O(log n log(1/ε)) time, O(k) edges have to be added and deleted. Therefore inserting a point takes O (log n log(1/ε) + k) |Π + | = O d (log n log(1/ε) + k) log(1/ε)/ε d time total. Deletions are handled similarly.
The total construction time follows by inserting each of the points into the dynamic data structure.

Dynamic approximate nearest neighbors
Another application of the same data structure in Theorem 4.2 is supporting (1+ε)-approximate nearest neighbor queries. In this scenario, the data structure must support insertions and deletions of points and the following queries: given a point q, return a point t ∈ P such that q − t ≤ (1 + ε) min p∈P q − p .
Proof: Maintain the data structure of Lemma 4.1 for all locality-sensitive orderings of Theorem 3.10, with one difference: Since the input is monochromatic, for each locality-sensitive ordering σ ∈ Π + , we store the points in a balanced binary search tree according to σ. The space and update time bounds easily follow by the same analysis. Given a query point q ∈ [0, 1) d , for each of the orderings the algorithm inspects the predecessor and successor to q. The algorithm returns the closest point to q encountered. We claim that the returned point p is the desired approximate nearest neighbor.
Let p ∈ P be the nearest neighbor to q and = q − p . By Theorem 3.10, there is a locality-sensitive ordering σ ∈ Π + such that the σ-interval I = [p , q) contains points that are of distance at most ε from p or q (and this interval contains at least one point of P , namely, p ). Note that no point of P can be at distance less than ε to q. Thus, the point p ∈ P adjacent to q in I is of distance at most ε from p . Therefore, for such a point p, we have p − q ≤ p − p + p − q ≤ (1 + ε) .
The final query time follows from the time taken for these predecessor and successor queries, as in the proof of Lemma 4.1.

Conclusion
In this paper, we showed that any bounded subset of R d has a collection of "few" orderings which captures proximity. This readily leads to simplified and improved approximate dynamic data structures for many fundamental proximity-based problems in computational geometry. Beyond these improvements, we believe that the new technique could potentially be simple enough to be useful in practice, and could be easily taught in an undergraduate level class (replacing, for example, well-separated pair decomposition-a topic that is not as easily accessible).
We expect other applications to follow from the technique presented in this paper. For example, recently Buchin et al. [BHO19] presented a near linear-sized construction for robust spanners. The idea is to build a robust spanner in one dimension, and then obtain a robust spanner in higher dimensions by applying the one-dimensional construction using the locality-sensitive orderings. are here modulo n), and the family of segments (i.e., edges) of K n that are orthogonal to this segment. This family is also a matching M i of size n/2 − 1. Observe that σ i = M i ∪ M i forms a Hamiltonian path, as shown in Figure A.1. Since the slopes of the segments in M i and M i are unique, for i = 0, . . . , n/2 − 1, it follows that σ 0 , . . . , σ n/2−1 are an edge-disjoint cover of all the edges of K n by n/2 Hamiltonian paths. If n is odd, use the above construction for n + 1, and delete the redundant symbol from the computed orderings.
A.2. Proof of Lemma 3.7 (shifting) For two positive real numbers x and y, let x % y = x − y x/y .
The basic idea behind shifting is that one can pick a set of values that look the "same" in all resolutions.
Proof: We start with the assumption that d is even (this assumption will be removed at the end of the proof). Let ∈ N, such that for α = 2 − , we have (d + 1) p − q < α ≤ 2(d + 1) p − q .
Let X = {i/(d + 1) | i = 0, . . . , d} be the set of shifts considered. Since we are shifting a grid with side length α, the shifting is periodical with value α. It is thus sufficient to consider the shifts modulo α.
The set B 1 is either an interval of length |p 1 − q 1 | ≤ p − q < α/(d + 1), or two intervals (of the same total length) adjacent to 0 and α. In either case, B 1 can contain at most one point of αX = X % α, since the distance between any two values of αX is at least α/(d + 1), by Lemma A.1.
Thus, the first coordinate rules out at most one candidate shift in X % α. Repeating the above argument for all d coordinates, we conclude that there is at least one shift in αX that is good for all coordinates. Let β = αi/(d + 1) ∈ αX this be good shift. Namely, p and q belong to the same cell of G + β. The final step is to observe that shifting the points by −β, instead of the grid by distance β has the same effect (and −β % α ∈ αX), and as such, the canonical cell containing both p and q is in the quadtree T as desired, and the side length of this cell is α.
Finally, if d is odd, replace d by d + 1 in the above proof. This results in a set of d + 2 = 2 d/2 + 1 = D + 1 shifts.