Finding the Largest Disk Containing a Query Point in Logarithmic Time with Linear Storage

Let D be a set of n disks in the plane. We present a data structure of size O(n) that can compute, for any query point q, the largest disk in D that contains q, in O(log n) time. The structure can be constructed in O(n log3 n) time. The optimal storage and query time of the structure improve several recent results on this and related problems [1, 2, 4].


INTRODUCTION
Let D be a set of n disks in the plane. We present a data structure of size O(n) that can compute, for any query point q ∈ R 2 , the largest disk in D that contains q, in O(log n) time. The structure can be constructed in O(n log 3 n) time.
For simplicity, we assume general position of the disks in D, meaning, in particular, that all disks are of different sizes,

Background.
The problem of constructing an efficient data structure for finding the largest disk containing a query point appears to have been first considered by Augustine et al. [1] (see also the later version of their paper [2]), as a subproblem that arose in their solution of the problem of finding the largest disk containing a query point, under the condition that the disk does not contain any point of an n-element input point set P (the largest P -empty disk containing q). They presented two solutions for this problem. The first solution uses a divide-and-conquer approach that produces a data structure of size O(n log n) that can answer a query in O(log 2 n) time. Another solution uses a simple sweeping technique that produces a data structure of size O(n 2 ) that can answer a query in O(log n) time. A subsequent paper by Kaplan and Sharir [4], considering the same problem studied in [1,2], presents an improved solution that uses only nearlinear storage, with O(log 2 n) query time. It is argued in [4] that the center of the largest P -empty disk containing a query point q must lie either on an edge of the Voronoi diagram of P , or at a Voronoi vertex (assuming that the query point lies inside the convex hull of P ). Surprisingly, finding the largest P -empty disk containing q whose center lies in the relative interior of some Voronoi edge can be done in O(log n) time using a data structure of linear size [4]. In contrast, finding the largest P -empty disk containing q and centered at a Voronoi vertex (these are the Delaunay disks of P ), with a structure of near-linear size, could only be done in [4] in O(log 2 n) time (using the same idea as in the first solution of Augustine et al. [1], which also requires Θ(n log n) storage).
This leads to a special case of the problem studied in this paper: Given the O(n) Delaunay disks of P , preprocess them into a data structure of linear size, so that the largest disk containing a query point can be found in O(log n) time. Kaplan and Sharir present some partial results, where the query time improves to O(k log n), for any prespecified paramenter k, but the storage grows to O(n 1+ 1 k ).
To recap, the failure of the previous works to solve the problem with optimal query time and storage makes it an interesting challenge: Given n disks in the plane, construct a data structure of linear size that can find, in O(log n) time, the largest disk containing a query point.
Our algorithm meets this challenge, as specified. The only (slightly) suboptimal performance parameter of our algorithm is the preprocessing, which takes O(n log 3 n) time. In particular, this improves the result of [4], yielding an overall algorithm that preprocesses a set P of n points in the plane, in O(n log 3 n) time, into a data structure of linear size, that can find, in O(log n) time, the largest P -empty disk containing a query point.
We note that this problem is a special case of a more general range searching setting where ranges have priorities (in our case the size of the disk is its priority) and we want a data structure that can find the range of highest priority, containing a query point.

Overview
We first describe the data structure and its high-level construction. Then we present and analyze the querying procedure. Finally, we provide a detailed description of an efficient implementation of the construction of the structure.
Construction of the data structure.
The algorithm divides each disk into three equal parts, called the right, top, and bottom parts, by the radii at orientations π 3 , π , and − π 3 (see Figure 1). The algorithm will be run separately on all the right parts of the disks, on all the top parts, and on all the bottom parts. The resulting substructures will then be combined into one global structure. For simplicity, and with no loss of generality, we will only describe the algorithm for the right portions of the disks.
The algorithm constructs a planar map Mr, over the right portions, with the following properties: 1. Each disk contributes at most one connnected arc to Mr.
2. No two arcs in Mr cross each other 1 . 3. For each q ∈ R 2 , let Dmax(q) denote the largest disk in D that contains q. Suppose that q lies in the right portion of Dmax(q). Then the first arc of Mr hit by the rightwarddirected ray emanating from q is the arc that Dmax(q) contributes to Mr.
Properties (1) and (2) also hold for the two other maps. Property (3) holds too, except that the relevant ray emanates from q in direction 2π/3 (for the map of the top parts) or in direction −2π/3 (for the map of the bottom parts).
Properties (1) and (2) imply that all the maps have linear complexity. Property (3) suggests that one should construct a point location structure on Mr for locating the first arc that lies straight to the right from a query point, and construct similar structures for the other two maps, with respect to the corresponding ray orientations ±2π/3 mentioned above. By combining the results from all three point location answers, one can easily find Dmax(q): it is the largest disk that contains q among the three retrieved disks. See Figure 2 for an illustration.  . Note that the map returns the correct answer for q1 but not for q2, because q2 does not lie in the right portion of the largest disk containing it.

Construction of Mr: High level description
This section presents a high-level description of the construction of the map Mr. An actual efficient implementation of this construction will be described later in Section 1.3.
As stated above, we divide each disk into three parts. Each part contributes at most one arc (a subarc of its boundary arc) to the corresponding map. As already stated, we focus only on the right part of each disk, and on the corresponding map Mr. For each disk d ∈ D we denote by T d the right part of d, and by A d the right arc (the arc bounding T d ). For each arc A d , we go over all disks larger than d, and each such disk d might shrink A d into a potentialy smaller subarc A d d (possibly eliminating it altogether). This yields, which, as will be seen immediately, is a single (possibly empty) connected subarc, is added to Mr. (This description can trivially be turned into an O(n 2 ) algorithm for constructing Mr; a more efficient near-linear construction is described in Section 1.3.) There are two rules for creating A d d from A d and d , which depend on the number of connected components of A d \T d .
1 Figure 3(a). 2. If A d \T d consists of two connected components 3 then, if the center of disk d is higher (in the y-direction) than the Each of these rules creates a single (potentialy smaller) subarc of A d , and thus, as already noted, In some cases A * d might be empty, and then the arc A d does not contribute anything to Mr, or A * d might be equal to A d , and then the arc is not affected by other disks (for instance, this is always the case for the largest disk in D). This implies the first property postulated for Mr. It is easy to see that, after the execution of these rules on an arc A d and a disk d which is larger than d, the resulting subarc A d d does not cross the arc A d , although it might have one or both endpoints lying on A d .
this implies the second propery of Mr. To complete the analysis, we next establish property (3), the main property of the map.
Lemma 1. For each q ∈ R 2 , let d = Dmax(q) be the largest disk of D that contains q. If q belongs to the right portion T d of d, then the first arc of Mr to the right of q is A * d .
Proof. First we note that it suffices to prove the lemma for the simpler case where there are only two disks, that is, D = {d, d }. Indeed, if the lemma were false, the ray emanating from q would not have hit A * d first. That is, it would have either hit first another arc A * d , or reach infinity without hitting any arc, and then the point where the ray hits A d (which always exists) must have been removed by another disk d . It is easily seen that in either case, the same situation would arise in the presence of just d and the other disk d or d .
Suppose first that d is smaller than d. In this case, by construction, A d is not affected by d , and A d d does not enter the region T d , thus rendering the lemma trivial. Suppose then that d is larger than d, so q / ∈ d . Note that in this We may assume, without loss of 3 It is easy to check that A d \ T d cannot have more than two connected components, because T d and T d are homothetic -see later in the paper.
generality, that the center of d is lower (in the y-direction) than the center of d ; the case when the center of d is higher is handled in a fully symmetric manner. Let r d and r d denote the respective radii of d and d.
We need to show that either A d d is the only arc that is to the right of q, or else it comes before (that is, to the left of) A d (clearly, since d is larger, A d appears in its entirety in the map of only the disks d, d ).
First, for any point (x0, y0) ∈ R 2 and any compact geometric object A, define the (rightward) distance in the xdirection from (x0, y0) to A by distx ((x0, y0) The analysis relies on the following simple but crucial property. Consider the region L d of all points p in the plane such that distx(p, T d ) ≤ r d (see Figure 4). Then, as follows by simple geometry, L d ⊂ d . We will also consider the region K d of all points p in the plane such that distx(p, A d ) ≤ r d (see Figure 5). Since Consider the rightward-directed ray v emanating from q.    Figure 7. Let l, l denote the horizontal lines touching the top and bottom vertices of T d , respectively (see Figure 6). Clearly the top vertex c of T d lies above l , and since the center of d is lower than the center of d , and r d < r d , the point c has to lie below the line l. In conclusion c lies between l and l . Observe also that c is behind (in the x-direction) T d , for otherwise, using the fact that both the top and the bottom straight edges of T d are outside T d , it would be impossible for ∂T d and ∂T d to cross each other, contrary to assumption. Denote by a the top intersection point of A d and ∂T d . Using the fact that c is outside and behind T d and between l and l , and the fact that the top subarc ac of A d does not cross ∂T d (except touching it at a), we conclude that a lies on one of the straight edges of T d .
We next claim that the point a lies above the center of d. half of A d and the bottom edge of T d cross each other at most once. This means that at least one intersection point lies on A d , which, as we have just argued, must be the lower point a (because a lies on an edge of T d ). This however is impossible, because a lies to the left of a, and thus it lies to the left of A d , contrary to assumption. This contradiction establishes our claim.
To proceed, we consider the possible ways in which A d can intersect ∂T d twice (see Figure 7). As proven before, the top intersection point of A d and ∂T d lies on one of the edges of T d . It is impossible that both intersection points lie on the top edge of T d , for then the center of d would have to be higher than the center of d , as is easily checked. This leaves us with four subcases: Either (i) both intersection points lie on the bottom edge of T d (see Figure 7(a)), or (ii) one intersection point lies on A d and one on the top edge of T d (see Figure 7(b)), or (iii) one intersection point lies on the bottom edge and one on the top edge of T d (see Figure  7(c)), or (iv) one intersection point lies on A d and one on the bottom edge of T d (see Figure 7(d)).  The proof below deals with all of these situations in the same manner. The proof-related Figures 6 and 8 are shown for situation 7(c), but the proof applies, as is, for the other cases as well. Recall that we have assumed that the center of d is below the center of d (in the y-direction), so that A d d is the bottom part of A d . As noted before, we only need to prove that the intersection point I of A d with the ray v belongs to A d d . Suppose to the contrary that this is not the case. Then either I is in the middle part of A d or I is in the top part (see Figure 8) . An almost identical proof to the one in case 1 shows that if I is in the middle part of A d then q ∈ d , contrary to our assumption. Suppose then that I is in the top part of A d .
Denote by b the point of intersection of ∂T d and the leftwarddirected ray emanating from a; see Figure 6. Since |ba| ≤ r d < r d , we get that b lies in L d . By what has been argued above, b lies on the top edge e of T d . Since e is parallel to the top left edge e * of L d , starts (at its bottom) below e * , and is shorter than e * , it follows that the top endpoint c of e lies in L d . In conclusion, b and c both lie in L d and outside T d . The top subarc ac of A d is the graph of a monotone decreasing function, both of whose endpoints lie in L d . It then easily follows that the entire arc is contained in L d . Since b lies on the top edge of T d , the triangle-like region abc, bounded by ab, bc, and the arc ac, is fully contained in L d . Since q lies in this region by assumption, it follows that q ∈ L d ⊂ d , contrary to our assumption. Hence I must lie in A d d , as claimed. This concludes the proof of the lemma, and thus establishes property (3) of Mr. 2 We summarize the results of this section in the following theorem.
Theorem 2. Given a set D of n disks in the plane, one can construct a data structure of linear size, consisting of (point location structures for) the map Mr and its two symmetric counterparts Mt and M b , constructed respectively over the top parts and over the bottom parts of the disks of D, such that, for a given query point q ∈ R 2 , the largest disk of D containing q is the largest of the disks that contain q among the three disks dr, dt, d b where dr is the disk whose arc A * dr is the first arc of Mr hit by the rightward directed ray from q, and where dt, d b are similarly defined for Mt, M b , respectively, and for the respective rays in directions 2π/3, −2π/3. The query time is O(log n).
Remark. The reason for dividing each disk into three parts is to ensure that L d ⊂ d (and thus also K d ⊂ d) for each disk d. Both properties fail if T d is larger than a third of a disk.

Efficient Construction of Mr
As already noted, the operational definition of the map Mr, as given in Section 1.2, leads to a straightforward and simple O(n 2 ) algorithm for constructing the map. We now describe a more efficient procedure for constructing Mr, which runs in O(n log 3 n) time.
Fix a disk d ∈ D, and let D d denote the set of all disks in D larger than d. Let T d denote the collection of the right portions T d of all the disks d ∈ D d , and let U d denote their union. Since the elements of T d are homothetic copies of one another, their union has linear complexity; see [5,6].
Before we proceed, we first establish the following lemma. For an arc A d of some disk d, and a point p ∈ A d in the top (resp., bottom) half of A d , we define the conjugate pointp of p (with respect to A d ) to be the second intersection point of A d and the vertical line through p; see Figure 9(a).
Lemma 3. Let d, d ∈ D such that d is larger than d and the center of d lies above (resp., below) the center of d (in the y-direction). Let p ∈ A d \T d be a point in the top (resp., bottom) half of A d . Then the conjugate pointp of p (with Proof. See Figure 9(b) for an illustration. We may assume, without loss of generality, that the center of d lies above the center of d; the complementary case can be handled in a fully symmetric manner. In this case p lies in the top half of A d andp lies in the bottom half. Suppose to the contrary thatp lies in T d . Let l be the vertical line through p andp. Let u and v denote the two intersection points of l with ∂T d , with u lying above v; these points must exist, for otherwisē p would trivially lie in A d \ T d . Observe that either u lies on the top edge of T d and v on the bottom edge, or both points lie on A d . In either case, the midpoint w of uv has the same y-coordinate as the center of d , and therefore must lie above the midpoint p0 of pp, whose y-coordinate is equal to that of the center of d. Since p lies outside T d andp lies inside, it follows that u lies between p andp and v lies belowp. But then w must lie below p0, as is easily checked, a contradiction that completes the proof.
be a point in the top (resp., bottom) half of A d . Then the conjugate pointp of p (with respect to A d ) is also in A d \U Consider first the following subproblem, which arises as a major step in the construction. We have a set E − = {d − 1 , . . . , d − k } of k "small" disks, and a set A − = {A1, . . . , A k } of noncrossing arcs, so that Aj is a subarc of the arc bounding the right portion T d − nodes v of Q. We construct these unions in a bottom-up manner, from the leaves of Q towards its root. The construction of the leaves is trivial, because at each leaf the union involves a single region T d . Let v be a non-leaf node of Q with children w,z. Then U + v = U + w ∪ U + z . if v has s leaves in its subtree, then each of U + w , U + z , U + v has O(s) complexity. This means that U + v can be constructed by a straightforward line sweeping procedure over the overlay of U + w and U + z , in time O(s log s). Adding up the costs, over all nodes v of Q, all the unions U + w can be constructed in a total of O(n log 2 n) time.
In conclusion, we have presented a procedure that, given two maps M − r and M + r , constructed respectively over the n/2 smaller disks of D and over the n/2 larger disks, merges them into the final map Mr, in O(n log 2 n) time. Denoting by T (n) the maximum time for the algorithm to run on a set of n disks, we obtain the recurrence relation: T (n) = 2T ( n 2 ) + O(n log 2 n), and thus T (n) = O(n log 3 n).
Remark. As described, the preprocessing algorithm uses O(n log n) space (for maintaining all the sets Sv, Dv). To impove the storage requirement to linear, we construct Q, and the corresponding sets Sv, Dv, in an incremental bottomup manner, maintaining at each step the sets Sv, Dv only within a single level of Q. The information concerning the sets Dv and the unions of their disks is easy to transfer from each level to the next one up. To obtain the sets Sv within a level the simplest way is to search in Q with the centers of disks of D − from scratch, only until the desired level. This implementation takes only linear space.
Putting everything together, and summarizing the statement of Theorem 2, we obtain the following summary result of this paper.
Theorem 6. Let D be a set of n disks in the plane. One can preprocess D into a data structure of linear size, in time O(n log 3 n), so that, for any query point q we can report the largest disk of D that contains q or determine that there is no such disk, in O(log n) time.
Remark. Although this is somewhat marginal, it would be interesting to reduce the cost of the preprocessing.