Subquadratic Algorithms for Some \textsc{3Sum}-Hard Geometric Problems in the Algebraic Decision Tree Model

We present subquadratic algorithms in the algebraic decision-tree model for several \textsc{3Sum}-hard geometric problems, all of which can be reduced to the following question: Given two sets $A$, $B$, each consisting of $n$ pairwise disjoint segments in the plane, and a set $C$ of $n$ triangles in the plane, we want to count, for each triangle $\Delta\in C$, the number of intersection points between the segments of $A$ and those of $B$ that lie in $\Delta$. The problems considered in this paper have been studied by Chan~(2020), who gave algorithms that solve them, in the standard real-RAM model, in $O((n^2/\log^2n)\log^{O(1)}\log n)$ time. We present solutions in the algebraic decision-tree model whose cost is $O(n^{60/31+\varepsilon})$, for any $\varepsilon>0$. Our approach is based on a primal-dual range searching mechanism, which exploits the multi-level polynomial partitioning machinery recently developed by Agarwal, Aronov, Ezra, and Zahl~(2020). A key step in the procedure is a variant of point location in arrangements, say of lines in the plane, which is based solely on the \emph{order type} of the lines, a"handicap"that turns out to be beneficial for speeding up our algorithm.


Introduction
Let A and B be two sets, each consisting of n pairwise disjoint line segments in the plane, and let C be a set of n triangles in the plane. We study the problem of counting, for each triangle ∆ ∈ C, the number of intersection points between the segments of A and those of B that lie inside ∆. We refer to this problem as within-triangle intersection-counting. This is one of four 3Sum-hard problems (among many others) studied by Chan [15], all of which can be reduced to the problem just mentioned. 1 The other three problems are: 2 (i) Intersection of three polygons. Given three simple n-gons A, B, C in the plane, determine whether A ∩ B ∩ C is nonempty.
(ii) Coverage by three polygons. Given three simple n-gons A, B, C in the plane, determine whether A ∪ B ∪ C covers a given triangle ∆ 0 .
(iii) Segment concurrency. Given sets A, B, C, each consisting of n pairwise disjoint segments in the plane, 3 determine whether A × B × C contains a concurrent triple.
Chan [15] presents slightly subquadratic algorithms for all four problems, whose running time in the standard real-RAM model (also referred to as the uniform model) is O((n 2 / log 2 n) log O(1) log n).
He has observed that, as already mentioned, all these problems can be reduced in near-linear time to the within-triangle intersection-counting problem, so it suffices to present an efficient subquadratic solution for that problem.
We study the within-triangle intersection-counting problem in the algebraic decision-tree model. In this model only sign tests of polynomial inequalities of constant degree that access explicitly (the endpoint coordinates of) the input segments (or vertices of the input triangles) count towards the running time. All other operations cost nothing in the model, but are assumed not to access the input segments explicitly. Although originally introduced for establishing lower bounds [9], the algebraic decision-tree model has become a standard model for upper bounds too, used in the study of many problems, including the 3Sum-problem itself [14,19,22,25,27] and various 3Sum-hard geometric problems [5,7,19]. One can interpret the decision-tree model as an attempt to isolate and minimize the cost of the part of the algorithm that explicitly accesses the real representation of the input objects, and ignore the cost of the other purely discrete steps. This has the potential of providing us with an insight about the problem complexity, which might eventually lead to an improved solution also in the uniform real-RAM model.
We show that the within-triangle intersection-counting problem and, hence, also problems (i)-(iii), can be solved in this model with O(n 60/31+ε ) sign tests, for any ε > 0. Chan [15] also remarks (without providing details) that his algorithm can be implemented in O(n 2−δ ) time in the algebraic decision-tree model, for some δ > 0 that he left unspecified. (With some care, as was communicated to us, one can obtain δ ≈ 0.01.) Our algorithm is rather different from Chan's, and gives the concrete value δ = 2/31, as mentioned above. Our techniques appear to be of independent interest and to have the potential to apply to other problems, as we demonstrate in Section 4.
If the segments in A and B and the triangles in C were all full lines (disjointness then of course cannot be assumed in general, although it might occur when the lines in each set are parallel, as in the dual version of the GeomBase problem [21]), then, in general, determining the existence of a concurrent triple of lines in A × B × C, that is, finding an intersection point of a pair of segments (lines) in A × B inside a degenerate triangle (line) of C, is the concurrency testing problem. This is the dual version of the classical 3Sum-hard collinearity testing problem, in which we are given three sets of points in the plane, and wish to determine whether their Cartesian product contains a collinear triple. This problem has recently been studied in the algebraic decision-tree model by Aronov et al. [5], in a restricted version where two of the sets are assumed to lie on two constant-degree algebraic curves.
The problems studied here can be regarded as other dual versions of collinearity testing, where restrictions of a different kind are imposed. As noted by Chan [15], the additional disjointness properties that are assumed here make the problem simpler than collinearity testing (albeit by no means simple), and its solution appears to have no bearing on the unconstrained collinearity problem itself. In Section 5 we comment on the substantial differences between this work and the work by Aronov et al. [5].
Our technique is based on hierarchical cuttings of the plane, as well as on tools and properties of segment-intersection range searching. We also use the so-called Fredman's trick in algebraic-geometric settings, in which the problem is mapped into a primal-dual range searching mechanism involving points and surfaces in R 6 . This reduction exploits the very recent multi-level polynomial partitioning technique of Agarwal et al. [3] (see also a similar technique of Matoušek and Patáková [29]). Our range searching mechanism of points and algebraic surfaces in higher dimensions is a by-product of our analysis, which appears to be broadly applicable to other range-searching applications, and we thus regard it as a technique of independent interest; see, for example, Proposition 3.2 and its proof.
Point location in arrangements. An additional key ingredient of our approach involves point location in an arrangement of lines in the plane (or an arrangement of curves, or in higher dimensions). This is of course a well studied problem with several optimal solutions [31], but we adapt and use techniques that are handicapped by the requirement that each operation that examines the real parameters specifying the lines involves at most three input lines. In contrast, the persistent data structure of [31] needs to sort the vertices of the arrangement from left to right, and each comparison in this sorting is of the x-coordinates of a pair of vertices, which are in general determined by the parameters of four input lines. The persistent data structure method has been used in [5,15] for the study of other 3Sum-hard geometric problems. Here we replace this approach with one that uses solely the relative positions of triples of lines, the so-called order type of the arrangement. In this approach each comparison involves only three input lines, which, as we show, eventually leads to improved performance of the algorithm.
In standard settings, separating the order-type computation from the rest of the processing makes no sense. This is because obtaining the full order-type information for N lines also takes Θ(N 2 ) time. This makes the approach based on the order type noncompetitive, as one can just do point location in the line arrangement, in the uniform model, with O(N 2 ) preprocessing. Nevertheless, in the applications considered in this paper (see Sections 3 and 4), the input lines have a special representation, which allows us to avoid an explicit construction of their order type and obtain this information implicitly in subquadratic time in the decision-tree model. The rest of the preprocessing, which takes quadratic time and storage in the uniform model, costs nothing in the decision-tree model.
The problem of determining whether and how the order type of an arrangement is sufficient to construct an efficient point-location data structure has, to the best of our knowledge, never been addressed explicitly. As we believe that this kind of "handicapped" point location will be useful for other applications (some of which are mentioned in Section 4), we present it in some detail in Section 2. We also present extensions of this technique to arrangements of constant-degree algebraic curves in R 2 , and to arrangements of planes or hyperplanes 4 in higher dimensions, which will be used in the applications in Section 4.
The algorithm for solving the within-triangle intersection-counting problem in the algebraic decision-tree model, and, consequently, also of the other three problems listed at the beginning of this section, is then presented in Section 3. Additional applications of our technique are presented in Section 4; they include: (i) counting intersections between two sets of pairwise disjoint circular arcs inside disks, and (ii) minimum distance problems between lines and two sets of points in the plane.

Order type-based point location in arrangements
Order types. An arrangement of non-vertical lines in the plane (and, later, curves in the plane, or hyperplanes in higher dimension) can be described in the following combinatorial fashion. We use the notion of an order type, defined for a set L of lines as follows: Given any ordered triple of lines ( 1 , 2 , 3 ) from L, where both 2 and 3 intersect 1 , we record the left-to-right order of the intersections 1 ∩ 2 and 1 ∩ 3 along 1 ; they might coincide. The totality of this information gives, for each line in L, the left-to-right order of its intersections with every other line it meets. For completeness, we assume the existence of an "infinitely steep" line ∞ , placed sufficiently far to the left, the order of whose intersections with the "normal" lines encodes the order of their slopes. This information is dual to the perhaps more familiar notion of an order type for a set of points in the plane (see, e.g., [23]). A higher-dimensional analog of this information involves recording the order in which a line that is the intersection of d − 1 hyperplanes in R d meets the remaining hyperplanes that meet but do not contain it. We also assume a suitable analog of the "infinitely steep line," recursively defined over the dimension.
Back in the plane, the permutations along each line of the intersection points with the other lines are called local sequences [24]. This view allows us to extend the definition of the order type to x-monotone curves, where each pair of curves is assumed to intersect in at most s points, for some constant s. In this case the order type gives, for each curve γ in the collection, the labeled left-to-right sequence of intersection points with the other curves, where each intersection point is labeled by the triple (i, j, k), where i and j are the indices of the two curves that form the intersection, and k indicates that it is the kth leftmost intersection point of the two curves. The order type also includes the vertical order of the curves at x = −∞. See Section 2.2 for further details.
The significance of the order type is that (a) it only records information for (d + 1)-tuples of objects, and (b) it contains enough information that lets us construct the arrangement and preprocess it for fast point location, without having to access further the real parameters that define the objects.
The problem we tackle now is the following: Given the order type of an arrangement, preprocess this information into a point location data structure. The preprocessing stage is not allowed to access the actual geometric description of the objects, such as the coefficients of the equations defining the lines, curves or hyperplanes, but can only exploit the discrete data given by the order type. A query, in contrast, is allowed to examine the coefficients of the few objects that it encounters.
We present two solutions for this problem. First, we show that, for d-dimensional hyperplane arrangements, for any d ≥ 2, the sampling method of Meiser [30] (see also [18]) can be implemented using only order-type information (we get the case of lines in the plane as a special case). Second, we show that for arrangements of x-monotone curves in the plane, a simple variant of the separatingchain method for point location [17,28] can be implemented such that only order-type information is used during the preprocessing.

Sampling-based approach for hyperplane arrangements
Let H be a set of N non-vertical hyperplanes in R d , where d ≥ 2 is a fixed constant. We want to construct the arrangement A(H) induced by H, where we are only given the order type of H. Essentially, we are given, for each intersection line formed by d − 1 hyperplanes, the order of its intersections with the other hyperplanes. (Alternatively, we are given, for each simplex σ formed by d + 1 of the hyperplanes, the left-to-right order of the vertices of σ.) We only require H not to contain vertical hyperplanes. We do permit more than d hyperplanes to share a point, as well as other degeneracies. This is indeed a natural scenario for our applications including segment intersection counting and its related problems.
We briefly sketch the randomized method first proposed by Meiser [30] and analyzed in detail by Ezra et al. [18], and show that the order type information is sufficient to construct the data structure.
Before considering the point-location structure, we note that the order type suffices to construct a discrete representation of the arrangement A(H), in which each j-dimensional cell of A(H), for j = 1, . . . , d, stores the set of all (j − 1)-dimensional cells that form its boundary (and consequently of all cells, of all dimensions, on its boundary), with respective back pointers from each cell to all higher-dimensional cells that contain it on their boundary. This can be done, e.g., by the Folkman-Lawrence topological representation theorem for oriented matroids [20], which, roughly speaking, implies that, given the order type of H, one can construct a combinatorial representation for the arrangement A(H), consisting of all sign conditions. That is, each face f of A(H) (of any dimension) is encoded by a sign vector {−1, 0, +1} |H| representing the above/below/on relation of f with respect to each hyperplane in H; see [13] for an inductive proof for the planar case, and its generalization to higher dimensions in [12]. Given this property, a naïve actual construction of the combinatorial representation of A(H) is easy to derive, and is free of charge in the decision-tree model, once the order type of H is computed.
Preprocessing. Given the arrangement A(H) and a fixed ε > 0, we first construct a random sample S of O( d 2 ε log d ε ) hyperplanes of H; the size of S does not depend on n. We then compute a canonical triangulation of the arrangement A(S). For each face of A(S), of any dimension ≥ 2, we use a fixed rule to designate a reference vertex p of this face. For example, we can take p to be the lexicographically smallest vertex of the face, with each vertex represented by the lexicographically smallest d-tuple of the indices of the hyperplanes that contain it and whose intersection is a single point. 5 We then triangulate each face f of A(S) by the fan obtained by adding vertex p to each simplex in the triangulations of the lower-dimensional faces composing the boundary of f and not incident to p. Next, we construct the conflict list for each simplex ∆ of the triangulation, of any dimension, defined as the set of hyperplanes of H that cross ∆, i.e., intersect, but not fully contain, it. The conflict list can indeed be constructed using only the order type: Deciding whether a hyperplane h ∈ H belongs to the conflict list of ∆ amounts to testing whether there exist two vertices of ∆ that lie on different sides of h, and each such test is an orientation test of the corresponding (d + 1)-tuple of hyperplanes: h and the d hyperplanes forming the vertex.
From standard results on ε-nets [26], a suitable choice of the constant of proportionality in the bound on the sample size guarantees that, with high probability, the conflict list size is not larger than εn, for each simplex ∆. It remains to recurse, for each simplex ∆ of the triangulation, with the hyperplanes in its conflict list. We therefore construct a hierarchical data structure that decreases the number of hyperplanes by a factor ε at each level. This continues until the number of hyperplanes falls below a suitable constant, at which point we simply store the remaining hyperplanes.
Answering queries. Each point-location query returns the relatively open simplex, of the suitable dimension, in the canonical triangulation of A(H) that the query point q lies in. 6 Queries are answered as follows. First, we locate the simplex ∆ of the canonical triangulation of A(S) containing the query point q. Since d is assumed to be constant, S is also of constant size, and so locating ∆ can be done in O(1) time. Next, we recurse in the data structure attached to ∆. When we reach a leaf of the hierarchy it remains to locate q, in the sense assumed above, in the arrangement of a constant number of hyperplanes stored at the leaf. This, combined with the information collected along the search path, identifies the cell that contains q. The overall number of these recursive steps is O(log n), and thus answering a query costs O(log n) arithmetic operations, where the hidden constant 7 is polynomial in d. The following lemma summarizes the result.

2.2
Level-based approach for the order type of x-monotone curves in the plane Let Γ = {γ 1 , . . . , γ n } be a collection of n x-monotone unbounded constant-degree algebraic curves in the plane, and let A(Γ) denote the arrangement induced by Γ. Let s = O(1) denote the maximum number of intersections between any pair of curves of Γ. We assume that the curves are in general position: there are no tangencies between the curves, and Γ does not contain vertical lines. Recall that the order type of Γ gives us the following information: • For each curve γ ∈ Γ, the left-to-right order of the intersection points of γ with the other curves of Γ; • The vertical order of the curves at x = −∞.
As already mentioned, each intersection point p is labeled by a triple (i, j, k) of indices, where γ i and γ j are the pair of curves that intersect at p, and 1 ≤ k ≤ s is the index of p, meaning that p is the kth leftmost intersection point of the two curves. Note that the order type tells us whether the kth leftmost intersection point of γ i and γ j lies to the left or to the right of, or coincides with the k th leftmost intersection point of γ i and γ j , for any quintuple of indices i, j, k, j , k . (Observe that the quintuple is defined by only three curves.) However, in this section we are not concerned with the actual construction of the order type-we simply assume it is given to us in advance. Such a construction, in a special context that arises in our applications, is considered when we discuss these applications, in Sections 3 and 4.
Recall that in the query phase we do have access to an explicit description of the curves. We assume a model of computation in which the following operations can be performed in O(1) time by the query algorithm: • Given a query point q and a curve γ j , decide whether q lies above, on, or below γ j .
• Given a query point q and an intersection point v that is labeled (i, j, k), decide if the x-coordinate of q is smaller than, equal to, or larger than, the x-coordinate of v.
Executing these basic operations is rather easy for lines (where we always have k = 1). When Γ contains higher-degree curves, however, executing the second operation is more involved. Concretely, comparing q to an intersection point v, labeled as (i, j, k), amounts to testing whether a certain quantified Boolean predicate P is satisfied. This predicate P depends on the real parameters specifying γ i and γ j and on the coordinates of q. It involves O(k) quantified variables that represent the k intersection points of γ i and γ j to the left of, and including, v, and consists of polynomial equalities and inequalities, whose number depends on k, of constant degree (which depends on the degree of the curves of Γ). Still, since k and the degrees of the curves are constant, the predicate P has constant complexity. Hence, its validity can be tested in O(1) time, for example using the algebraic algorithmic machinery developed in [8].
Preprocessing. Our point-location data structure is based on the separating-chain method for planar maps, due to Lee and Preparata [28], which was later refined by Edelsbrunner et al. [17]. For the case of x-monotone curves, the separating-chain method is especially easy to implement, since we can simply use the levels in the arrangement as separating chains. This allows to carry out the preprocessing using only order-type information, as explained next.
Observe that a doubly-connected edge list (DCEL) representation [10] of the arrangement A(Γ) can be constructed in O(n 2 ) time using only the given order-type information, without further accessing the real parametric representation of the curves. Specifically, the order type gives us the local sequences of intersection points along each curve, and, assuming for the moment general position, we can identify, for each intersection point, its four incident edges. Using this data we can trace the boundary of each 2-face of the arrangement, and consequently obtain the DCEL structure (observing that each face is x-monotone in this setup). Recall that we have assumed general position of the curves. Nevertheless, if more than two arcs meet at a vertex v, we also need to know the circular order of the incident curves around v, which we can deduce from the order of the curves at x = −∞ and from the indices of v along each curve, as we have assumed that all the crossings are proper. As this is not the scenario that we assume here, we omit further details of this extension.
Let Λ j , for j = 0, . . . , n − 1, denote the jth level in the arrangement A(Γ), that is, Λ j is the closure of the set of points that lie on the curves of Γ and have exactly j curves passing below them.
Note that the levels can easily be extracted from the DCEL of A(Γ), as the rule for constructing a level is to follow it from left to right, switching at each vertex to the other curve forming that vertex. (This latter rule has to be modified, in an easy manner, when more than two curves are incident to v.) We store each level Λ j as a sorted sequence of its vertices, in left-to-right order, where each vertex is represented as a triple (i, j, k), as explained above (when more curves are incident to the vertex, any one of the representing triples suffices).
Answering queries. To answer a query, we perform a binary search on the levels Λ 0 , . . . , Λ n−1 . At each step of this primary binary search we need to decide whether the query point q lies above, on, or below a level Λ j . We can do this by a secondary binary search, this time on the x-coordinates of the vertices of Λ j . This gives us an edge e of Λ j intersecting the vertical line through q. By comparing q to the curve γ i ∈ Γ defining e, we can determine the position of q relative to Λ j . If q lies on Λ j then we are done, otherwise we continue the primary binary search. When the query algorithm has finished, we have either identified an edge (or vertex) of A(Γ) containing q, or an edge immediately above (or below) q. Since the DCEL gives us, for each edge e of A(Γ), the two adjacent faces of A(Γ), we can now answer the query, returning the face, edge or vertex containing q.
The cost of the search is O(log 2 n) (where the constant of proportionality is a large, albeit constant, function of the degree of the curves of Γ).
Lemma 2.2 Let Γ be a set of n unbounded x-monotone constant-degree algebraic curves in the plane. Using only the order-type information of Γ, we can construct a data structure that uses O(n 2 ) storage and that allows us to answer point location queries in the arrangement A(Γ) in O(log 2 n) time.
Remarks. (1) The query time of the procedure described in Section 2.1 for d = 2 (which is O(log n)) is faster than the time of the procedure presented here for curves in the plane (which is O(log 2 n)). However, the preceding sampling-based method does not extend to non-straight curves, since there is no obvious way to extend the notion of a canonical triangulation to the case of curves. The only viable way of doing this seems to use the standard vertical-decomposition technique. Unfortunately (for us), constructing the vertical decomposition requires that we compare the x-coordinates of vertices defined by different, unrelated pairs of curves. Such a comparison involves four input curves and it cannot be resolved from the order type information alone. For lines in the plane, however, the above technique does yield the improved logarithmic query time.
(2) We have assumed that the given curves are constant-degree algebraic curves, but the same machinery would have worked if the curves were arbitrary and we have constant-time black-box routines that perform the two operations, testing whether a point lies above, below, or on a curve, and testing whether a point lies to the left or to the right of a specific intersection point of two curves.
(3) It is tempting to apply fractional cascading [16] to reduce the query time to O(log n). This is problematic in our context, however, because to implement fractional cascading, we must be able to merge suitable sorted subsequences of the sequences of vertices of different levels in the arrangement. Such a merge requires comparing the x-coordinates of two vertices on different levels, which is not possible using order type only.

The algorithm for within-triangle intersection-counting
Our input consists of two sets A, B, each of n pairwise disjoint segments in the plane, and of a set C of n triangles in the plane. To simplify the presentation, we assume that the input is in general position, namely that, among the segments of A, B, and edges of triangles of C, no two share a supporting line, and no endpoint of one segment lies on another (with the obvious exception of the vertices of a triangle in C). 8 These are the only general position assumptions that we need. A triple of segments (one from A, one from B, and an edge of a triangle from C) are allowed to be concurrent.
A high-level roadmap of the algorithm. To avoid various technical issues that complicate the description of our algorithm, we focus in this overview on the simpler segment concurrency problem, where C is a set of (not necessarily disjoint) segments, and the goal is to determine whether there is a triple (a, b, c) ∈ A × B × C of concurrent segments. To make the overview even simpler, assume that C is a set of lines.
We fix a parameter g n and put r := n/g. We construct a (1/r)-cutting Ξ(A) for the segments of A, and another such cutting Ξ(B) for the segments of B. Since the segments of A are pairwise disjoint, we can construct Ξ(A) of size O(r), and similarly for Ξ(B) (see [11]). We overlay the two cuttings and obtain a planar decomposition Ξ. While the complexity of Ξ is O(r 2 ), any line of C crosses only O(r) of its cells.
For each cell σ of Ξ, we preprocess the sets A σ ⊆ A and B σ ⊆ B of those segments that cross σ, each of size at most n/r = g, into a data structure that supports efficient queries, each specifying a line c and asking whether c passes through an intersection point of a segment of A σ and a segment of B σ . We pass to the dual plane, obtain sets A * σ and B * σ of at most g points (dual to the lines containing the segments) each. (We ignore here 'short' segments that have an endpoint inside σ; see below.) The query is a point c * and the task is to determine whether c * is collinear with a pair of points (a * , b * ) ∈ A * σ × B * σ . For a ∈ A σ and b ∈ B σ we define γ a,b to be the line that passes through a * and b * , and let Γ σ denote the collection of these lines. The query with c * then reduces to point location in the arrangement A(Γ σ ), where we only need to know whether c * lies on any of the lines. We cannot perform this task explicitly in an efficient manner, since the complexity of A(Γ σ ) is O(g 2 ) and we have O(r 2 ) = O(n 2 /g 2 ) such arrangements, of overall quadratic size. We can do it, though, in the algebraic decision-tree model, in an implicit manner, using the so-called Fredman's trick. Concretely, we apply the order-type based machinery of Section 2 to construct A(Γ σ ) and preprocess it for fast point location. More precisely, we first construct the order type of Γ σ : this involves, for each triple of lines γ a 1 ,b 1 , γ a 2 ,b 2 , γ a 3 ,b 3 , determining the ordering of their intersection points along each of these lines. We express this test as the sign test of some 12-variate constant-degree polynomial G(a 1 , a 2 , We map the triple (b 1 , b 2 , b 3 ) to a point in a six-dimensional parametric space, and (a 1 , a 2 , a 3 )to an algebraic surface ψ a 1 ,a 2 ,a 3 in this space, which is the locus of all triples We now need to locate the points (b 1 , b 2 , b 3 ) in the arrangement of the surfaces ψ a 1 ,a 2 ,a 3 , from which all the sign tests can be resolved, at no extra cost in the algebraic decision-tree model, thereby yielding the desired order type. The subsequent construction of the arrangement A(Γ σ ), and its preprocessing for fast point location, using the machinery in Section 2, also cost nothing in our model.
To make this process efficient, we group together all the points (b 1 , b 2 , b 3 ), over all cells σ, into one global set P , and group the surfaces ψ a 1 ,a 2 ,a 3 into another global set Ψ. We have Using the recent machinery of Agarwal et al. [3] (one can also consider the alternative technique of Matoušek and Patáková [29]), we can perform this batched point location in 6-space in time for any ε > 0. Full details of this step are given in Section 3.1.
Searching with the dual points c * takes O n 2 g log g time, because we have n query lines c, each line crosses O(r) = O(n/g) cells σ, and each point location with c * in each of the encountered arrangements takes O(log g) time. Balancing (roughly) this cost with the preprocessing cost, we choose g = n 2/31 , and obtain the total subquadratic running time O(n 2−2/31+ε ) = O(n 60/31+ε ).
Quite a few issues were glossed over in this overview. Since the segments of A and of B are bounded, a cell σ may contain endpoints of these segments, making the passage to the dual plane more involved. The same applies in the original segment intersection counting problem, where the triangles of C may have vertices or more than one bounding edge that lie in or meet σ. We thus need to handle the presence of such 'short' segments and/or 'short' triangles. Moreover, we need to count intersection points within each triangle, and the number of cells of the cuttings Ξ A , Ξ B that a triangle can fully contain is much larger than O(r). All these issues require more involved techniques, which are developed below. Still, the overall runtime of the resulting algorithm remains O(n 60/31+ε ), for any ε > 0.
Hierarchical cuttings. This ingredient is needed for counting intersection points in cells that are fully contained inside a query triangle. Fix a parameter g n and put r := n/g. We construct a hierarchical (1/r)-cutting Ξ(A) for the segments of A, which is a hierarchy of (1/r 0 )-cuttings, where r 0 is some sufficiently large constant. The top-level cutting Ξ 1 (A) is constructed for A. Since the segments of A are pairwise disjoint, we can construct Ξ 1 (A) so that it consists of only O(r 0 ) trapezoids (for concreteness, we write this bound as br 0 , for some absolute constant b), each of which is crossed by at most n/r 0 segments of A, which comprise the so-called conflict list of the cell σ, denoted as A σ . The construction time of Ξ 1 (A), in the real-RAM model, is O(n log r 0 ) = O(n). See [11, Theorem 1] for details.
For each cell σ of Ξ 1 (A), we clip the segments in its conflict list A σ to within σ and apply the cutting-construction step recursively to this set, clipping also the cells of the new cutting to within σ (and ignoring cells, or portions thereof, that lie outside σ, as they are not met by any of the clipped segments of A σ ). We denote the union of all the resulting (1/r 0 )-cuttings as Ξ 2 (A). We continue recursively in this manner, until we reach a level s at which all the cells are crossed by at most n/r segments. We thus obtain a hierarchy of cuttings Ξ 1 (A), Ξ 2 (A), . . . , Ξ s (A), for some index s = O(log r). We denote the collective hierarchy as Ξ(A). Since we stop the recursion as soon as n/r s 0 ≤ n/r, the overall number of cells of all the levels is O((br 0 ) s ) = O(r 1+ε ), for any prespecified ε > 0, for a suitable choice of r 0 = r 0 (ε). Technically, the trapezoids in the cutting are relatively open, and the cutting also includes one-and zero-dimensional cells; as the latter are easier to deal with, we will focus below on the two-dimensional cells of the cutting. At any level j of the hierarchy, the cells of Ξ j (A) are pairwise disjoint. As these cells partition the plane, each intersection point between a segment of A and a segment of B lies in precisely one cell of each level. See Figure 1 for an illustration. Figure 1: Interaction of a hierarchical cutting with a triangle. The dark grey cells are the ones inside the triangle at the top level of the hierarchy; the medium grey cells are the ones inside the triangle at the second level (and whose parent cells are not inside the triangle). The light grey cells will be refined and handled at lower levels, since they intersect the triangle boundary.
We apply a similar hierarchical construction for B, and let Ξ(B) = {Ξ j (B)} j≤s denote the resulting hierarchical cutting, which has analogous properties. (We assume for simplicity that the highest index s is the same in both hierarchies.) We now overlay Ξ(A) with Ξ(B), that is, at each level j of the hierarchy, we overlay the cells of Ξ j (A) with the cells of Ξ j (B). We denote the jth level overlay as Ξ j , and the entire hierarchical overlay structure as Ξ = {Ξ j } j≤s . Since each of Ξ j (A) and Ξ j (B) consists of at most (br 0 ) j cells, the number of cells of Ξ j is at most O((br 0 ) 2j ). Since we have r s 0 ≈ r (up to a factor of r 0 ), it follows that the overall complexity of all the overlays is O(r 2+ε ), provided that we choose r 0 , as above, to be sufficiently large, as a function of ε.
For simplicity of exposition, we ignore lower-dimensional faces of the cuttings, and regard each of the overlays Ξ j as a decomposition of the plane into pairwise openly disjoint convex polygons, each of complexity linear in j ≤ s = O(log r). Each cell σ of the overlay is identified by the pair (τ, τ ), where τ and τ are the respective cells of Ξ j (A) and Ξ j (B) whose intersection is σ; we simply write σ = (τ, τ ). Each bottom-level cell σ of the final overlay Ξ s is crossed by ≤ n/r = g segments of A and by ≤ n/r = g segments of B.
Classifying the segments and triangles. Let σ = (τ, τ ) be a cell of Ξ j , for any level j of the hierarchy. Call a segment e of A long (resp., short) within σ if e crosses σ and neither of its endpoints lies in σ (resp., at least one endpoint lies in σ). Let A l σ (resp., A s σ ) denote the set of long (resp., short) segments of A within σ. Apply analogous definitions and notations to the segments of B. Denote by C σ (resp., C (0) σ ) the set of triangles with at least one edge that crosses σ (resp., that fully contain σ). Call a triangle ∆ ∈ C σ long (resp., short) in σ if σ does not (resp., does) contain a vertex of ∆, and denote by C l σ (resp., C s σ ) the set of long (resp., short) triangles in C σ . For each triangle ∆ ∈ C, each of its edges crosses only O((br 0 ) j ) cells of Ξ j . Indeed, as such an edge crosses from one cell of Ξ j to an adjacent cell, it does so by crossing the boundary of either a cell of Ξ j (A) or a cell of Ξ j (B), and the total number of such crossings is O((br 0 ) j ). In particular, the edge crosses at most O(r 1+ε ) cells of the final overlay Ξ s . It follows that In contrast, ∆ can fully contain many more cells of Ξ s , perhaps almost all of them, but the hierarchical nature of the construction allows us to deal with a much smaller number of such interior cells, by collecting them at higher levels of the hierarchy; see below for details.
The algorithm: A quick review. The high-level structure of the algorithm is as follows (see also the 'roadmap' overview given earlier). We construct the hierarchies Ξ(A) = {Ξ j (A)} j≥1 and Ξ(B) = {Ξ j (B)} j≥1 . For each cell τ of Ξ j (A) (resp., τ of Ξ j (B)), we compute its conflict list A τ (resp., B τ ), which, as we recall, is the set of all segments of A that cross τ (resp., segments of B that cross τ ). We then form the hierarchical overlay Ξ = {Ξ j } j≥1 , and for each cell σ = (τ, τ ) of any overlay Ξ j , we compute the subset A σ of the segments of A τ that cross σ, and the subset B σ of the segments of B τ that cross σ. We partition A σ into the subsets A l σ and A s σ of long and short segments (within σ), respectively, and apply an analogous partition to B σ . The additional overall cost for constructing these sets, over all hierarchical levels, is O(r 2+ε · n/r) = O(nr 1+ε ) = O(n 2+ε /g).
(The cost at the bottom level dominates the entire cost over all levels.) We also trace each triangle c ∈ C through the cells of Ξ that are crossed by its edges, and form, for each cell σ of the overlay, the list C σ of triangles of C with at least one edge that crosses σ. We partition C σ into the subsets C l σ and C s σ , as defined earlier. As we show below, we can handle, in a much more efficient way, the short triangles of C s σ , as well as the triangles of C l σ all three of whose edges cross σ, simply because the overall number of such triangle-cell interactions is small. We therefore focus on the triangles of C l σ that have only one or two edges crossing σ. For triangles with two crossing edges we use a standard two-level data structure (where in each level we consider only one crossing edge). This lets us assume, without loss of generality, that each triangle in C l σ is a halfplane. Each of these halfplanes can be represented by its bounding line, that is the line supporting the appropriate crossing edge of the triangle. We flesh out the details below.
We also assume, for now, that all the segments of A σ and of B σ are long in σ (and so we drop the superscript l). This is the hard part of the analysis, requiring the involved machinery presented below. After handling this case, we will address the much simpler situations that involve short segments and/or short triangles (or triangles with three edges crossing σ). The cost of handling short segments or short triangles within cells is smaller, even in the uniform model, since the overall number of short objects within cells is smaller.
Handling the long segments. We preprocess each level j of the overlay, to compute, for each of its cells σ = (τ, τ ), the number of intersection points between the (long) segments of A σ and those of B σ (which, due to the clipping, lie in σ). This is a standard procedure that involves computing the number of pairs of segments from A σ × B σ whose intersection points with the boundary of σ interleave (these are precisely the pairs of intersecting segments), and can be implemented to take O((|A σ | + |B σ |) log(|A σ | + |B σ |)) time; see, e.g., [1]. We store the resulting count at σ.
Consider a cell σ, a segment a ∈ A σ , a segment b ∈ B σ , and a triangle ∆ ∈ C σ . By assumption, ∆ has only one edge c or two edges c 1 , c 2 crossing σ. When a and b intersect inside σ, the intersection lies in ∆ if and only if the triple (a, b, c), or each of the triples (a, b, c 1 ), (a, b, c 2 ), has a prescribed orientation, reflecting the condition that the point a ∩ b lies on the side of c (or the sides of c 1 , c 2 ) that contain ∆. This orientation (or orientations) can be positive, negative, or zero, depending on the relative order of the slopes of a, b, and c (or of c 1 and c 2 ), and on whether ∆ lies to the left or to the right of c (or of c 1 , c 2 ).
For each halfplane c + that represents a triangle ∆ ∈ C σ (the halfplane contains ∆ and is bounded by the line supporting the single (relevant) edge c of ∆ that crosses σ), we want either (i) to represent the set of pairs (a, b) ∈ A σ × B σ that have a prescribed orientation of the triple (a, b, c), as the disjoint union of complete bipartite graphs, or (ii) to count the number of such pairs. The subtask (i) arises in cases where ∆ has two edges crossing σ and is needed for the first level of the data structure, which we query with the first crossing edge of ∆. The subtask (ii) arises in the second level of the structure, which we query with the second crossing edge of ∆, and in cases where only one edge of ∆ crosses σ.
We also count the number of intersections within σ, in O ((|A σ | + |B σ |) log(|A σ | + |B σ |)) time. As a matter of fact, with a simple modification of the procedure, we can, within the same time bound, represent the set of all pairs of segments (a, b) ∈ A σ × B σ that intersect each other (inside σ) as the disjoint union of complete bipartite graphs, so that the overall size of their vertex sets is O ((|A σ | + |B σ |) log(|A σ | + |B σ |)). This follows from standard planar segment-intersection range searching machinery; see, e.g., [1]. In what follows we focus on just one such graph, and to simplify the presentation we denote it as A σ × B σ , with a slight abuse of notation.
Preparing for Fredman's trick. We use the infrastructure developed by Aronov et al. [5], with suitable modifications, but adapt it to the order-type context. We preprocess A and B into a data structure that we will then search with the points dual to the lines supporting the edges of the triangles of C. For each a ∈ A, b ∈ B, we define γ a,b to be the line that passes through a * and b * , where a * (resp., b * ) is the point dual to a (resp., b). By our general position assumption, a * = b * , so γ a,b is well defined. Let Γ 0 denote the set of these n 2 lines. Our goal in task (ii) is to count, for each cell σ of any of the overlays, for each point c * dual to an edge of a triangle ∆ ∈ C σ , the number of lines of Γ 0 that lie above c * , the number of lines that are incident to c * , and the number of lines that lie below c * . In task (i), we want to represent each of these sets of lines as the disjoint union of a small number of precomputed canonical sets. This calls for preprocessing the arrangement A(Γ 0 ) into a suitable point location data structure, which we will then search with each c * ∈ C * , and retrieve the desired data from the outcome of each query.
As in, e.g., [5], a naïve implementation of this approach will be too expensive. Instead, we return to the hierarchical partitions Ξ(A), Ξ(B), and Ξ, and iterate, for each level j of the hierarchy, over all cells σ = (τ, τ ) of Ξ j , defining Γ σ := {γ a,b | (a, b) ∈ A σ × B σ }. In principle, we want to construct the separate arrangements A(Γ σ ), over the cells σ, preprocess each of them into a point location data structure, and search, for each triangle ∆ ∈ C, in the structures that correspond to the cells of Ξ that are either crossed by (at most) one or two edges of ∆, or fully contained in ∆. This is also too expensive if implemented naïvely, so we use instead Fredman's trick, combined with the machinery developed in Section 2.
We first observe that, for each triangle ∆ ∈ C, finding the cells σ (at any level of the hierarchy) that ∆ fully contains is easy and inexpensive. We go over the hierarchy of the overlays Ξ j . At the root we find, by brute force, all the (constantly many) cells of Ξ 1 that ∆ fully contains, and add their intersection counts to our output counter. We then recurse, in the same manner, in the at most br 0 cells of Ξ 1 that ∆ crosses. Thus the number of cells we visit is at most O(r 2 0 ) · 1 + br 0 + (br 0 ) 2 + · · · + (br 0 ) s = O(r 1+ε ), so the overall cost of this step 9 is O nr 1+ε = 9 It is for making this step efficient that we use hierarchical partitions. A single-shot partition would have forced O n 2+ε /g .
We therefore focus, for each triangle ∆ of C, only on the cells that it crosses (at every level of the hierarchy), and restrict the analysis for now to cells at which ∆ is long, with at most two of its edges crossing the cell. Repeating most of the analysis just given, the number of these cells is O(r 1+ε ) (with a smaller constant of proportionality, since we now do not have the factor O(r 2 0 ), as above).
Constructing A(Γ σ ) in the decision-tree model. Consider the step of constructing A(Γ σ ) for some fixed cell σ. Following the technique in Section 2, we perform this step using only the order type of Γ σ , and we begin by considering the task of obtaining the order-type information. That is, we want to determine, for each ordered triple (γ a 1 ,b 1 , γ a 2 ,b 2 , γ a 3 ,b 3 ) of lines of Γ σ , whether the point γ a 1 ,b 1 ∩ γ a 2 ,b 2 lies to the left or to the right of the point γ a 1 ,b 1 ∩ γ a 3 ,b 3 . Let G(a 1 , a 2 , a 3 ; b 1 , b 2 , b 3 ) denote the 12-variate polynomial (of constant degree) whose sign determines the outcome of the above comparison. (The immediate expression for G is a rational function, which we turn into a polynomial by multiplying it by the square of its denominator, without affecting its sign; our general position assumption ensures that none of the denominators vanishes.) Once the signs of all expressions G(a 1 , a 2 , a 3 ; b 1 , b 2 , b 3 ) are determined, we can apply Lemma 2.1. The rest of the preprocessing, which constructs a discrete representation of the arrangement, say, in the DCEL format, and turns this representation into an efficient point location data structure, can be carried out at no cost in the algebraic decision-tree model.
We search the structure with each triangle ∆ ∈ C σ . We may assume that ∆ is long in σ and that only one or two edges of ∆ cross σ, as the other cases are easy to handle. Assuming further that there is only one such edge c, locating the dual point c * in A(Γ σ ) takes O(log g) time, as shown in Section 2 (noting that Γ σ consists of only g 2 lines). With suitable preprocessing, locating c * gives us, for free in our model, the three sets of the lines that pass above c * , are incident to c * , or pass below c * . The case where two edges of ∆ cross σ is handled using a two-level version of the structure; see below for details. The point location cost now goes up to O(log 2 g).
Consider then the step of computing the order type of the lines of Γ σ , that is, of computing the sign of G(a 1 , a 2 , a 3 ; b 1 , b 2 , b 3 ), for every triple of segments a 1 , a 2 , a 3 ∈ A σ and every triple of segments b 1 , b 2 , b 3 ∈ B σ . To this end, we play Fredman's trick. We fix a bottom-level cell τ of Ξ(A). For each triple (a 1 , a 2 , a 3 ) ∈ A 3 τ , we define the surface and denote by Ψ the collection of these surfaces, over all cells τ . We have N := |Ψ| = O((n/g) 1+ε · g 3 ) = O(n 1+ε g 2 ). Similarly, we let P denote the set of all triples τ , over all cells τ of Ξ(B). We have M := |P | = O(n 1+ε g 2 ). These bounds pertain to the bottommost level of the hierarchy; they are smaller at levels of smaller indices.
We apply a batched point-location procedure to the points of P and the surfaces of Ψ. The output of this procedure is a collection of complete bipartite subgraphs of P × Ψ, so that, for each such subgraph P α × Ψ α , G(a 1 , a 2 , a 3 ; b 1 , b 2 , b 3 ) has a fixed sign for all (b 1 , b 2 , b 3 ) ∈ P α and all (a 1 , a 2 , a 3 ) ∈ Ψ α . This tells us the desired signs of G (a 1 , a 2 , a 3 ; b 1 , b 2 , b 3 ), for every pair of triples (a 1 , a 2 , a 3 ) ∈ A 3 τ , (b 1 , b 2 , b 3 ) ∈ B 3 τ , over all pairs of cells (τ, τ ) ∈ Ξ(A) × Ξ(B), and these signs give us the orientation (i.e., the order of the intersection points) of every triple of lines γ a,b . That is, we the query to visit O(r 2 ) such cells, which would make it too expensive.
obtain the order type of the lines. As remarked in Section 2, we may assume that this also includes the sorting of the lines at x = −∞, but, for the sake of concreteness, we will address this simpler task in some detail later on.
Remark. This shuffling of the pairs (a 1 , b 1 ), (a 2 , b 2 ), (a 3 , b 3 ) into the triples (a 1 , a 2 , a 3 ), (b 1 , b 2 , b 3 ), and the treatment of the first triple as defining a surface in R 6 and of the second triple as defining a point in R 6 , is the realization of Fredman's trick in our context.

The batched point-location step
We now spell out the details of the batched point location procedure. It involves points and surfaces in a six-dimensional parametric space, and proceeds by using the recent multilevel polynomial partitioning technique of Agarwal et al. [3,Corollary 4.8]. Specialized to our context, it asserts the following result. Given a set Ψ of N constant-degree algebraic surfaces in R 6 , a set P of M points in R 6 , and a parameter δ, with 0 < δ < 1/6, there are finite collections Ω 0 , . . . , Ω 6 of semi-algebraic sets in R 6 with the following properties.
• For each index i, each cell ω ∈ Ω i is a connected semi-algebraic set of constant complexity.
• For each index i and each ω ∈ Ω i , at most N 4|Ω i | 1/6−δ surfaces from Ψ cross ω (meaning, as in the planar setup, that they intersect ω but do not fully contain it), and at most M 4|Ω i | 1−δ points from P are contained in ω.
• The cells partition R 6 , in the sense that where denotes disjoint union.
• The sizes of the collections Ω 0 , . . . , Ω 6 are bounded by a function of δ, and not of |P | and |Ψ|.
The sets in Ω 0 , . . . , Ω 6 can be computed in O(N + M ) expected time, where the constant of proportionality depends on δ, by a randomized algorithm. For each i and for every set ω ∈ Ω i , the algorithm returns a semi-algebraic representation of ω, a reference point inside ω, the subset of surfaces of Ψ that cross ω, the subset of surfaces that fully contain ω (for lower-dimensional cells ω), and the subset of points of P that are contained in ω.
We compute the partition of Theorem 3.1, for a suitable choice of δ, and find, for each ψ ∈ Ψ, the sets ω ∈ Ω i , over all i = 0, . . . , 6, that it crosses, and those that it fully contains. For each i and ω ∈ Ω i , let P i,ω denote the set of points of P in ω, and let Ψ i,ω denote the set of surfaces of Ψ that cross ω. We form three complete bipartite graphs P i,ω × Ψ 0 i,ω , P i,ω × Ψ + i,ω , and P i,ω × Ψ − i,ω , where Ψ 0 i,ω is the set of surfaces that fully contain ω (and thus also P i,ω ), and Ψ + i,ω (resp., Ψ − i,ω ) is the set of surfaces for which ω lies fully in their positive (resp., negative) side, that is, the side at which the corresponding values of G are positive (resp., negative). As the parameters of the partition are all constant, the overall size of the vertex sets of these graphs is O(M + N ). To simplify the notation, we refer to the combined size of the vertex sets of a complete bipartite graph as the size of the graph.
For each i and ω, we also have a recursive subproblem that involves P i,ω and the subset Ψ i,ω of the surfaces that cross ω. Putting r i := |Ω i |, for i = 0, . . . , 6, we have, for each i and ω, To handle each recursive subproblem, we pass to the dual 6-space, with the roles of a 1 , a 2 , a 3 and of b 1 , b 2 , b 3 swapped (such a swap is justified by the complete symmetry of the setup between the parameters a 1 , a 2 , a 3 and b 1 , b 2 , b 3 ), and apply, using Theorem 3.1, a similar partitioning. (We now denote the resulting collections as Ω * i and their respective sizes as r * i .) We obtain a second collection of complete bipartite graphs, still of overall size O(M + N ), now with a somewhat larger constant of proportionality, and a new set of recursive subproblems. Each of these subproblems can be labeled by the pairs (k, ω) and ( , ω * ), where k (resp., ) is the index i of the primal collection Ω i containing ω (resp., dual collection Ω * i containing ω * ). For each quadruple ((k, ω), ( , ω * )), the corresponding primal subproblem involves at most M We keep flipping between the primal and dual setups in this manner, until one of the parameters (number of points or number of surfaces) becomes smaller than some constant threshold n 0 , which is chosen to be sufficiently larger than all the (constant) parameters r k , r * . When this happens, we solve the problem by brute force, where the running time, and the overall size of the resulting collection of complete bipartite graphs, are both proportional to the value of the other parameter (number of surfaces or number of points, respectively).
The primal-dual recursion is applied whenever M ≤ N 6 and N ≤ M 6 . If M > N 6 we recurse only in the primal, and if N > M 6 we recurse only in the dual. We terminate, as before, when we reach subproblems where one of the parameters M , N becomes at most n 0 .
The resulting recursion has the following performance bounds. T (M, N ) denote the maximum possible sum of the sizes of the complete bipartite graphs produced by the recursive process described above, over all input sets of at most M points and at most N surfaces. Then we have

Proposition 3.2 Let
for any ε > 0, where the constant of proportionality depends on ε. The same asymptotic bound also holds for the cost of constructing these graphs.
Proof. We fix ε, and show, using induction on M and N , that for a suitable constant coefficient A that depends on ε. We use δ := ε/2 in Theorem 3.1; to simplify the calculations a bit, we will work with δ instead of ε, so we put ε = 2δ.
The base cases are when either M ≤ n 0 or N ≤ n 0 . If, say, M ≤ n 0 , then we clearly have the 'brute force' bound T (M, N ) ≤ n 0 N , which satisfies the bound in (1) if A is chosen sufficiently large. A symmetric treatment holds when N ≤ n 0 . Assume then that (1) holds for all M ≤ M , N ≤ N , where at least one of the inequalities is strict, for some parameters M , N (both greater than n 0 ), and consider an instance with a set P of M points and a set Ψ of N surfaces.
Assume first that N 1/6 ≤ M ≤ N 6 . We consider one phase of the primal decomposition followed by one phase of the dual decomposition. Fix two pairs (k, ω) (in the primal) and ( , ω * ) (in the dual), and follow the notations introduced above. Apply the induction hypothesis to the dual subproblem at ω * . As argued above, this subproblem involves at most M 16r 1−δ k (r * ) 1/6−δ dual surfaces (or primal points) and at most N 16r 1/6−δ k (r * ) 1−δ dual points (or primal surfaces). Hence, by the induction hypothesis, the contribution of this subproblem to T (M, N ) is at most We assume that the numbers r * are the same at each primal subproblem. We make this assumption for simplicity and clarity of presentation, but it can be removed with a more careful analysis. Multiplying by the number r k r * of subproblems with the indices k, , and simplifying the expressions, the contribution is at most A M 6/7+2δ N 6/7+2δ 16 12/7+4δ (r k r * ) 13δ/21−4δ 2 + (r * ) 5/6+2δ/3+2δ 2 Recall however that we are in the range M ≤ N 6 and N ≤ M 6 , so we have as is easily checked. The contribution is thus at most Multiplying by the number r k of subproblems, and simplifying the expressions, we get at most A M 6/7+2δ N 6/7+2δ Since N < M 1/6 , the third term is dominated by the second term, provided that n 0 is sufficiently large (recall that we have chosen it to be much larger than the quantities r k ). Using this fact and multiplying by the number, 7, of values of k, we establish the induction step for this range.
The case N > M 6 is handled in a fully symmetric manner, except that we only work in the dual. The details are fully symmetric to those in the preceding case, and are therefore omitted.
The running time of the procedure obeys the same asymptotic upper bound, which is a consequence of the fact that the multi-level cells in Ω 0 , . . . , Ω 6 and their conflict lists can be computed in O(M + N ) time. We omit the easy details.
This completes the proof of the lemma. 2 Remark. Proposition 3.2 can be extended to any dimension d, with a similar proof, to obtain a primal-dual range searching algorithm involving M points and N surfaces in d dimensions, assuming full symmetry between the points and surfaces, as above. The running time of the algorithm (in the uniform model) is O(M d/(d+1)+ε N d/(d+1)+ε + M 1+ε + N 1+ε ), for any ε > 0.

The rest of the algorithm
Using a similar and simpler technique, we can sort the lines of each of the arrangements A(Γ σ ), over all cells σ, at x = −∞. (Note that this corresponds to sorting them in reverse order of their slopes.) Here each comparison is between a pair of lines, say γ a 1 ,b 1 and γ a 2 ,b 2 , and its outcome is the sign of some constant-degree 8-variate polynomial (more precisely, a rational function turned into a polynomial) H(a 1 , a 2 ; b 1 , b 2 ). Fredman's trick for this setup leads to a batched point location procedure that involves O((n/g) 1+ε g 2 ) = O(n 1+ε g) points and O((n/g) 1+ε g 2 ) = O(n 1+ε g) surfaces in R 4 . This task can be accomplished by a considerably simpler variant of the same technique presented above, whose running time bound is subsumed in the above bound.
In summary, the information collected so far allows us to obtain the combinatorial structure of each of the arrangements A(Γ σ ), over all cells σ of Ξ, and subsequently construct an order-type-based point-location data structure for each of them, at no extra cost in the algebraic decision-tree model. The overall cost of this phase, in this model, is thus O (n 1+ε g 2 ) 12/7+ε , for any ε > 0. By replacing ε by some small multiple thereof, we can write this bound as O (ng 2 ) 12/7+ε , for any ε > 0.
Fredman's trick, as applied here, separates the handling of the conflict lists A τ , over the trapezoids τ of Ξ(A), and the conflict lists B τ , over the trapezoids τ of Ξ(B). For a cell σ = (τ, τ ) of Ξ, not all the segments in A τ necessarily cross σ, so we have to retain (for σ) only those that do cross it, and apply a similar pruning to B τ . The cost of this filtering step is O(g) for each σ, for an overall cost of O((n/g) 2 · g) = O(n 2 /g), which is a cost that we are happy to incur as it is subsumed by the cost of searching with the elements of C, discussed next.
Interpreted in the dual, this step filters out all lines γ a,b from Γ σ that pass through a (dual) point whose (primal) segment does not cross σ, but we also need to filter out lines γ a,b , where the corresponding (long) segments a and b do not meet inside σ (or do not meet at all). Filtering by inspecting all pairs (a, b) would be too expensive in the uniform model, but, fortunately, we can implement this step free of charge in the decision-tree model. Indeed, consider the complete bipartite graphs in the compact representation of all the long pairs (a, b) that intersect inside σ (as constructed above). Once this complete bipartite decomposition is available, we simply keep in Γ σ only those lines that correspond to the edges of these graphs, a step that costs nothing in the decision-tree model, since it does not incur any extra comparisons among the input segments. Once this filtration is performed, we can construct the arrangement of the surviving lines, at no extra cost, and use the modified arrangement for the point location searches with the elements of C, discussed next.
Searching with the elements of C. We now need to search the structures computed in the preceding phase with the dual features of the triangles of C.
Each triangle ∆ ∈ C crosses only O(r 1+ε ) = O(n 1+ε /g) cells of Ξ. As already observed, handling the cells that ∆ fully contains is simpler and cheaper. (As a matter of fact, this part can be performed in the real RAM model, and so the main effort is in handling the bottom-level cells that are crossed by ∆, as described next.) Recall that, for a cell σ that ∆ crosses, we say that ∆ is long (resp., short) in σ if σ does not contain (resp., contains) a vertex of ∆. There are at most three cells σ, at the bottom level of the hierarchy, in which ∆ is short, and we simply inspect all the g 2 pairs of segments in A σ × B σ , and include those pairs that intersect inside ∆ in our output count for ∆, for a total cost of O(ng 2 ). It therefore suffices to focus on cells in which ∆ is long. ∆ is not processed at intermediate-level cells at which it is short; it is only processed as a short triangle at the relevant bottom-level cells.
Let σ be such a bottom-level cell. Using the non-planarity of K 3,3 , it is easy (and standard) to show that there is at most one cell σ that is crossed by all three edges of ∆, so we can handle these cells as the cells where ∆ is short, with comparable efficiency. It thus suffices to assume that σ is crossed by only one or two edges of ∆. In the former case we may replace ∆, for searching within σ, by the halfplane bounded by the single edge that crosses σ, and in the latter case we may replace ∆ by the intersection wedge of the two halfplanes bounded by the two edges that cross σ. In the former situation we replace ∆ by the point c * dual to the line supporting the single crossing edge, and search the point location structure constructed for A(Γ σ ) with c * . In the latter situation we replace ∆ by the pair of points c * 1 , c * 2 dual to the lines supporting the two crossing edges. We prepare a two-level data structure, where each level is based on the above point location structure for A(Γ σ ), except that the first level collects its output as the disjoint union of canonical sets, and the second level counts intersections within the query triangle. We then search the top level with c * 1 and search the resulting substructures of the second level with c * 2 . There are O(nr 1+ε ) = O(n 2+ε /g) triangle-cell crossings, each requiring O(log 2 g) search time, using (one or two levels of) the above point location data structure for each such arrangement, for a total of O n 2+ε log 2 g g time, or O (ng 2 ) 12/7+ε + n 2+ε log 2 g g in total. We (nearly) balance this bound by taking g = n 2/31 , so the cost of this procedure, in the algebraic decision-tree model, is O(n 2−2/31+ε ) = O(n 60/31+ε ), for any ε > 0.
We next have to handle short segments and short triangles within cells of Ξ (including triangles that have three edges crossing the cell). As might be expected, this part is less expensive than the handling of long segments and triangles, as we now show.
Handling short segments. There are two main tasks that we have to implement for short segments: (i) count the number of intersection points that involve a short segment and another segment, at all cells of the overlays at all levels, and (ii) preprocess them so that, for each bottomlevel cell σ, we can count, for each query triangle ∆, the number of intersection points with a short segment within σ that lie inside ∆. We start with the first task.
A segment of either A or B can be short in at most two cells, at each level of the hierarchy. For each cell σ at any fixed level j, let n σ denote the number of short segments (from A σ ∪ B σ ) in σ, so we have σ∈Ξ j n σ ≤ 4n. For each cell σ, the overall number of segments that cross σ is at most 2n/r j 0 .
Thus, at each cell σ at level j, we count the number of intersections between the n σ short segments and the at most 2n/r j 0 other (long or short) segments. Following standard techniques, such as in [1], this takes O n 2/3 σ (n/r j 0 ) 2/3+ε + n 1+ε σ + (n/r j 0 ) 1+ε time (also in the uniform model). By Hölder's inequality, the sum of these bounds over the cells σ is at most Recalling that r j 0 ≤ r s 0 = O(r 1+ε ) = O(n 1+ε /g), this can be upper bounded by O(n 4/3+ε + n 1+ε r j 0 ) = O(n 2+ε /g), for a slightly larger ε (assuming that g < n 2/3 , as indeed will be the case), a cost that is subsumed by that of other steps of the algorithm. Consider next the second task, of counting the number of intersection points inside a query triangle that involve a short segment, at the bottom-level cells. The overall number of such intersection points is only O(ng), and we compute all of them by brute force, and distribute them among the cells. For each bottom-level cell σ, let P σ denote the set of these points in σ, and let C σ denote, as above, the set of triangles that cross σ, with only one or two crossing edges. To simplify the presentation, we only consider triangle-cell crossings for which the triangle has just one crossing edge, so it behaves as a halfplane in the cell. The case of two crossing edges is handled, as above, via a two-level data structure. Put M σ := |P σ | and N σ := |C σ |, for each cell σ, and observe that (i) Applying the standard machinery for halfspace range counting (see [2,4]), we can count, also in the uniform model, the number of points of P σ that lie inside (the halfplanes representing) each of the triangles in C σ , σ , for each cell σ. Summing this bound over σ, using Hölder's inequality, we get a total of This bound is subsumed in the overall bound on the cost of the other steps of the algorithm, as described in Section 3 (again, assuming that g is not too large).
Handling short triangles and triangles with three crossing edges. As we have already noted, the overall cost of this part is O(ng 2 ). Indeed, each triangle ∆ is short in at most three cells, at each level of the hierarchy. However, we need to count intersection points inside a short triangle only at the bottom-level cells where the triangle is short. For each such cell σ, we count for each triangle ∆ that is short in σ, by brute force, the number of intersection points inside ∆ ∩ σ, and this indeed has a total cost of O(ng 2 ), well below our overall bound. The same argument applies to triangles with three edges crossing a bottom cell.
We remark that the analysis of these parts of the algorithm, which deal with short segments or triangles, also applies in the uniform model.
Putting it all together. In conclusion, we finally have: Theorem 3.3 Let A and B be two sets each consisting of n pairwise disjoint segments in the plane, and let C be a set of n triangles in the plane. We can count, for each triangle ∆ ∈ C, the number of intersection points of segments of A with segments of B that lie inside ∆, in the algebraic decision-tree model, at the subquadratic cost O(n 60/31+ε ), for any ε > 0.

Extensions
In this section we give a few additional applications of the paradigm developed in this paper.

Circular arc intersection counting
We have two sets A, B, each consisting of n pairwise disjoint circular arcs in the plane, and a third set C, consisting of n circles in the plane. Our goal is to count, for each circle c ∈ C, the number of intersection points of an A-arc with a B-arc that lie in the interior of c. Denote byγ the circle containing γ, for each arc γ ∈ A ∪ B. PutĀ = {γ | γ ∈ A} andB = {γ | γ ∈ B}.
Using the standard lifting transform, each circle a ∈Ā is lifted to a 'red' plane a * in R 3 , and each circle b ∈ B is lifted to a 'blue' plane b * in R 3 . For each a ∈Ā, b ∈B, the line λ a,b = a * ∩ b * intersects the standard paraboloid Π in at most two points, and the lifted images of the at most two intersection points of the arcs supported by a and b form a subset of zero, one, or two of these points. Let P denote the set of these points on Π, keeping only the points that correspond to actual intersection points of an A-arc and a B-arc. We have |P | ≤ 2n 2 . Given a circle c ∈ C (call such circles 'green'), we want to count the number of points of P that lie below or on the plane c * .
We dualize the setup in R 3 , using the standard duality that preserves the above/below relationship, and get a set P * of at most 2n 2 'red-blue' dual planes (all tangent to Π). The goal is now to locate the points dual to the planes of C * in the arrangement A(P * ) of the planes of P * . More precisely, we want to count how many planes pass below (or through) each query point.
We thus face the problem of point location in a three-dimensional arrangement A(P * ) of a set P * of O(n 2 ) 'red-blue' planes, each determined by a red arc in A and a blue arc in B. Of course, we cannot afford the construction of the full arrangement, so we play Fredman's trick, as in Section 3. That is, we construct a (1/r)-cutting Ξ A for the A-arcs, and a (1/r)-cutting Ξ B for the B-arcs, each of complexity O(r) (which follows since the arcs in each set are pairwise disjoint), construct the overlay Ξ of these cuttings, and process each cell σ of Ξ separately. We actually need to construct hierarchical cuttings, as in Section 3, and, at each cell σ of the hierarchy of Ξ, at any level, we also need to count the overall number of intersections of A-arcs and B-arcs that lie inside σ (this information will be needed when σ is fully contained inside a circle of C). As before, we classify each arc of A ∪ B at a cell σ as long (resp., short) if the cell does not contain (resp., contains) an endpoint of the arc. It suffices to focus on long arcs, as short arcs can be handled in much the same way as in Section 3.
As demonstrated in Section 3, this subtask is very easy for (long) segments, but is more challenging for circular arcs. Still, using the algorithm of Agarwal et al. [6], this can be done, for the long arcs within each cell σ, in O(N 3/2+ε σ ) time, for any ε > 0, where N σ = |A σ | + |B σ |, and A σ (resp., B σ ) is the set of (long) arcs of A (resp., B) that cross σ. We have |A σ |, |B σ | ≤ g := n/r.
At each bottom-level cell σ of the hierarchy of Ξ, we need to construct, and preprocess for fast point location, the arrangement A(P * σ ), where P * σ is the set of all dual red-blue planes in R 3 that are determined by an arc of A σ and an arc of B σ .
We now use the machinery developed in Section 2. Here we need to perform orientation tests for quadruples of planes in P * σ , and Fredman's trick allows us to represent each such test as a truth test of some constant-complexity algebraic predicate G in 24 variables, 12 variables for the parameters of the four circles of A participating in the test, and 12 variables for the parameters of the four circles of B.
In more detail, each plane participating in the orientation test is dual to a point that is the intersection of Π with some line λ a,b . There are at most two such points, but for such a point to actually materialize, it needs to belong to the two arcs a, b. We assume for now that each of these arcs is long in σ (the other cases are much easier to handle). We first need to distinguish between the two possible points, which differ by the sign of the square root in the solution of the resulting quadratic equation. Once that is done, and the four intersection points participating in the orientation test have been identified, the test itself is the sign test of a fixed algebraic expression, but in order to be applicable, we need to assert that each of the four relevant points p (within the xy-plane) lie in σ (since we assume that our arcs are long in σ, this suffices to ensure that the two arcs do indeed intersect at p). Put together, all these constraints define our desired predicate, which clearly is of constant complexity.
We transform these tests into point-location tests of g 4 points, formed by quadruples of circular arcs of A, in an arrangement of g 4 surfaces, formed by quadruples of circular arcs of B, in R 12 , or the other way around (since we will also use duality, in which we flip the roles of A and B, so that the dual points are determined by arcs of B and the dual surfaces are determined by arcs of A). Again, since the arcs are assumed to be long, specifying the three real parameters that define the containing circle, and knowing σ, uniquely identifies the arc. (The intersection of an arc with a cell σ does not have to be connected. If it is not connected, we treat each of its connected components as a separate arc.) We group together all these points and surfaces, over the O(r) = O(n/g) (bottom-level) cells of Ξ A (for the points) and of Ξ B (for the surfaces) into single respective collections Q, Σ, consisting of O((n/g) 1+ε g 4 ) = O(n 1+ε g 3 ) points and surfaces, respectively. (As just mentioned, and as we did in Section 3, we use duality, so we also treat Q as a collection of dual surfaces and treat Σ as a collection of dual points in R 12 .) Adapting the machinery in Section 3.1 (see the remark at the end of that section), we can solve the latter point-location problem in time O (n 1+ε g 3 ) 24/13 = O n 24/13+ε g 72/13 , for any ε > 0. From the output of this procedure we can construct, using the random sampling machinery in Section 2.1, and at no extra cost in the algebraic decision-tree model, a data structure for point location in A(P * σ ), for each bottom-level cell σ of Ξ, where the cost of a query is O(log g). Arguing as in the preceding section, each circle of C has to perform this search at only O(n 1+ε /g) cells, so the total cost of the point-location searches with the circles of C is O n 2+ε log g g . Balancing (roughly) this cost with the preprocessing cost, we choose g := n 2/85 , and the overall cost of the procedure is (the subquadratic bound) O n 168/85+ε , for any ε > 0. That is, we have Theorem 4.1 Given sets A, B, each of n pairwise disjoint circular arcs in the plane, and a set C of n circles in the plane, we can count, for each circle c ∈ C, the number of intersection points of an A-arc with a B-arc that lie in the interior of c, in O n 2−2/85+ε = O n 168/85+ε time, for any ε > 0, in the algebraic decision-tree model.

Points and lines in the plane: Minimum distance problems
In the problem studied in this subsection we have two sets A, B, each of n points in the plane, and a third set C of n lines in the plane, and the goal is to determine whether there exist a triple (a, b, c) ∈ A × B × C, such that c contains a point x that satisfies some property involving dist(x, a) and dist(x, b). For a concrete example, to be expanded below, given a prescribed parameter t > 0, determine whether any line c ∈ C contains a point whose sum of distances to its nearest neighbor in A and its nearest neighbor in B is at most t. Equivalently, determine whether any c ∈ C intersects any ellipse of major axis t whose pair of foci lie in A × B.
The problem, in detail. Let A and B be two sets, each of n points in the plane, and let C be a set of n lines in the plane. Consider predicates of the form (where a and b are points, c is a line, and t is a real number) where F is a constant-degree bivariate piecewise algebraic function that is monotone increasing in both variables, and dist is the Euclidean distance. Typical examples are F (u, v) = u + v, F (u, v) = max{u, v}, or F (u, v) = u 2 + v 2 . Our goal is to determine whether there exist a triple (a, b, c) ∈ A × B × C such that π(a, b, c; t) holds. For example, when F (u, v) = max{u, v}, the goal is to determine whether there exists a line of C that contains a point that lies at distance at most t from a point of A and from a point of B. Similarly, when F (u, v) = u + v, the goal is to determine whether there exists a line c ∈ C that intersects any 'bichromatic' ellipse of major axis t that is spanned by a focus in A and a focus in B. Problems of this kind are special instances of facility location, where we want to determine whether there exists a line of C that contains a point whose distance from A and distance from B satisfy some property. Alternatively, we can aim at reporting all lines of C with this property.
A more ambitious goal (but perhaps not that much more) would be to find the minimum value of t for which there exist (a, b, c) ∈ A × B × C such that π(a, b, c; t) holds, or for which every c has a pair (a, b) such that π(a, b, c; t) holds. For example, for F (u, v) = u + v, find the smallest major axis of a bichromatic ellipse of this kind that is crossed by some line of C, or find the smallest major axis of a bichromatic ellipse so that every line of C crosses such an ellipse.
We will consider here only the former setup, in which t is prespecified. It seems likely that the problem of optimizing t could be solved using parametric search.
The problems studied here can be generalized in several ways, for example by replacing the lines of C by constant-degree algebraic curves, or by replacing the Euclidean distance by more general distance functions, but we will deal only with the problem as formulated above.
For each triple (a, b, c) ∈ A × B × C, eliminate x from the expression in (2) that determines π(a, b, c; t), to obtain a semi-algebraic region G(a, b; t) in the dual plane (in which lines are represented as points), of constant complexity, so that c ∈ G(a, b; t) if and only if π(a, b, c; t) holds.
The algorithm. We present a solution for the above problem, that runs in (significantly) subquadratic time in the algebraic decision-tree model. 10 We remark that the problem can be solved in quadratic time in the uniform model, as will follow from the algorithm that we will derive; see a comment below to this effect.
By the preceding discussion, we face the problem of point location (of the points dual to the lines of C) in the planar arrangement A(G) of the set G of the 'red-blue' regions G(a, b; t), each being a semi-algebraic set of constant complexity, and determined by a red point a ∈ A and a blue point b ∈ B. As with the previous problems, we cannot afford the construction of the full arrangement, so we play Fredman's trick, similar to, but in a somewhat different context than, the technique in Section 3.
We take a random sample R A of r points from A, and a random sample R B of r points from B, construct their Voronoi diagrams Vor(R A ) and Vor(R B ), and triangulate each cell of the diagrams by triangles emanating from the site of the cell. We denote the resulting triangulated diagrams as Ξ A and Ξ B , respectively. Each triangulated diagram has complexity O(r). Each cell τ of Ξ A (resp., of Ξ B ) has an associated conflict list A τ (resp., B τ ), of those points of A (resp., of B) that can be closer to a point in τ than the site of τ . With high probability, the size of each conflict list is at most O n r log r . We overlay Ξ A and Ξ B , and obtain a subdivision Ξ of the plane, with O(r 2 ) constant-complexity cells. (For problems of this kind, there is no need for a hierarchical decomposition, like the ones used in Section 3 and in some of the preceding subsections.) Let σ be a cell of Ξ, formed by the intersection of a cell τ of Ξ A and a cell τ of Ξ B , and let A σ (resp., B σ ) be the points of A τ (resp., of B τ ) that can be closer to points in σ than the corresponding sites.
A line c ∈ C crosses only O(r) cells of Ξ. Within each such cell σ, each point x ∈ c ∩ σ needs to find its nearest neighbor a x in A, among the points of A σ , and its nearest neighbor b x in B, among the points of B σ , and then test whether there exists x ∈ c ∩ σ such that F (dist(x, a x ), dist(x, b x )) ≤ t. To do so, within each of these O(r) cells, we need to locate the dual point c * of c in the arrangement A(G σ ), where 11 G σ = {G(a, b; t) | a ∈ A σ , b ∈ B σ }. More precisely, we need to determine whether c * lies in any of these regions.
We now use the machinery developed in Section 2. Here we need to perform orientation tests for triples of boundary curves of the sets G(a, b; t), for (a, b) ∈ Γ := σ (A σ × B σ ). The curves bounding the regions G(a, b; t) are not necessarily x-monotone and may be bounded. This requires some modification of the technique of Section 2.2, which, albeit technically somewhat involved, are nonetheless rather straightforward conceptually, and we omit their details, in the interest of brevity.
The construction of the order type of the curves bounding the regions G(a, b; t) amounts to performing various tests, each of which involves three pairs in Γ, plus some additional parameters that specify which curves we test and what are the two intersection points that we compare. We employ Fredman's trick, which transforms each such test, involving three pairs (a 1 , b 1 ), (a 2 , b 2 ), (a 3 , b 3 ), to testing whether the point (b 1 , b 2 , b 3 ) ∈ R 6 belongs to a certain semi-algebraic region Q a 1 ,a 2 ,a 3 , which consists of all points (u 1 , u 2 , u 3 ) such that (a 1 , u 1 ), (a 2 , u 2 ), (a 3 , u 3 ) satisfy the conditions in the test. Glossing over some technical issues, this amounts to batched point location of O(ng 2 ) points in an arrangement of O(ng 2 ) surfaces in R 6 . Applying the machinery in Section 3.1, this can be done in time O n 12/7+ε g 24/7+ε , for any ε > 0. This allows us to construct the arrangements A(G σ ), over the cells σ, preprocess each of these arrangements for fast point location, as in the preceding applications, at no extra cost in the decision-tree model.
As before, searching with the lines of C takes O n 2+ε g log 2 g time, and balancing the two costs yields the earlier bound O n 60/31+ε , for any ε > 0. That is, we have Theorem 4.2 Let A and B be two sets, each of n points in the plane, let C be a set of n lines in the plane, let F be a constant-degree bivariate piecewise algebraic function that is monotone increasing in both variables, and let t be a real parameter. We can determine, for each line c ∈ C whether it contains a point x that satisfies F (dist(x, a), dist(x, b)) ≤ t, where dist is the Euclidean distance. The algorithm works in the algebraic decision-tree model, and takes O n 60/31+ε time, for any ε > 0.
Remark. As promised, we note that the above algorithm can be adapted, in a much simplified form, to obtain a quadratic algorithm for the problem in the uniform model. To do so, we construct the full Voronoi diagrams Vor(A) and Vor(B), and form their triangulated overlay Ξ. This step takes O(n 2 ) time. For each cell σ of Ξ, all its points have the same nearest neighbor a σ in A and the same nearest neighbor b σ in B. Then, for each c ∈ C, we find the O(n) cells of Ξ that c crosses, and, for each such cell σ, we need to test whether c * lies in G(a σ , b σ ; t), an operation that takes O(1) time. The overall cost of this step is also O(n 2 ).

Discussion
As promised in the introduction, we make some comments on the differences between this work and the work of Aronov et al. [5], which tackle problems that have some features in common. Both works use Fredman's trick, implemented by an offline range-search mechanism, in which objects in one input set form points and objects in another set form surfaces in some suitable parametric space. However, the analysis in [5] works in the dual plane and uses hierarchical polynomial partitioning for points (dual to the lines in the input). This mechanism works efficiently only in the special case where one of the input sets consists of arbitrary points in the plane, and the other two sets are contained in one-dimensional curves. In this work, we apply a decomposition in the primal plane (the plane of the segments), and use hierarchical cuttings, where the crucial property in the analysis is that each set A, B consists of pairwise disjoint segments. This results in a special, low-complexity structure, which our analysis exploits. In addition, we present a new primal-dual range searching mechanism, exploiting the recent multi-level polynomial partitioning technique of [3]. This mechanism is fairly general and we feel that it could be used in other range searching applications as well, and is therefore of independent interest.
Another major difference is the use of order types to construct the various arrangements A(Γ σ ). The fact that each comparison that we make involves only three objects of A and three of B, allows us to transform it into a test that involves a point and a surface in six dimensions. In contrast, the standard technique, based on persistent data structures, calls for sorting the vertices of A(Γ σ ) in the x-direction, and then each test involves a point and a surface in eight dimensions. This makes the resulting range searching machinery considerably less efficient. It is an interesting topic for further research to find additional applications of this paradigm. Puzzlingly, the use of order types seems inapplicable to the most efficient method presented in [5].
Finally, it would be interesting to modify our techniques so as to obtain (slightly) subquadratic algorithms for these problems in the uniform model; see Chan [15].