### On Constant Factors in Comparison-Based Geometric Algorithms and Data Structures

Timothy M. Chan, Patrick Lee
2014 Annual Symposium on Computational Geometry - SOCG'14
Many standard problems in computational geometry have been solved asymptotically optimally as far as comparison-based algorithms are concerned, but there has been little work focusing on improving the constant factors hidden in big-Oh bounds on the number of comparisons needed. In this paper, we consider orthogonal-type problems and present a number of results that achieve optimality in the constant factors of the leading terms, including: 1 constant δ > 0. For randomized median-finding
more » ... ms  , both the upper and lower bound on the expected number of comparisons are 1.5n ± o(n). For heap building [27, 35] , the best upper bound is 1.625n + O(lg n lg * n) and the best lower bound is about 1.37n. The list goes on. By contrast, not much work has been done regarding constant factors of comparison-based algorithms in the computational geometry literature. The present paper investigates this research direction. There are obviously a limitless number of problems in our field that one might consider, not all are worth pursuing from this new perspective, but we will pick several representative problems that have fundamental importance and that require nontrivial interesting techniques to find the best constant factors, not just straightforward modifications of existing algorithms. We choose mainly orthogonal-type problems where the obvious definition of a "comparison" sufficescomparing of two coordinate values of two input points, or in the case of a data structure problem, comparing the coordinate value of a query point with an input point. Results. The highlights of our results are listed below: 1. We can compute the h maxima among a set of n points in 2D by an output-sensitive algorithm that uses n lg h + O(n √ lg h) comparisons (see Section 2.1 or 2.2). 2. We can compute the maxima among a set of n points in 3D by a randomized algorithm that uses n lg n + O(n √ lg n) expected number of comparisons (see Section 2.3). By contrast, the previous algorithm requires about 2n lg n comparisons. 3. We can compute the h maxima among a set of n points in 3D by a randomized output-sensitive algorithm that uses n lg h + O(n lg 2/3 h) expected number of comparisons (see Section 2.4). 4. We can detect whether a set of n line segments, each vertical or horizontal, by a randomized algorithm that uses n lg n + O(n √ lg n) expected number of comparisons (see Section 2.5). By contrast, the trivial algorithm requires 3n lg n comparisons. For reporting all k intersections, the number increases by an O(k) (or better) term. The same result holds for computing vertical decomposition of n horizontal line segments. 5. We can build a data structure for a set of n disjoint boxes in 3D so that we can locate the box containing a query point using (3/2) lg n + O(lg lg n) comparisons (see Section 3.3). 6. We can build a data structure for a subdivision of space into n disjoint boxes in 3D so that we can locate the box containing a query point using (4/3) lg n + O(lg lg n) comparisons (see Section 3.4). All of the above bounds are optimal except for the lower-order terms (see Appendix A for lower bound proofs for items 1 and 4). Items 5-6 may be viewed as 3D generalizations of a result by Seidel and Adamy  , who previously showed that 2D point location queries can be answered using lg n + O( √ lg n) comparisons. Some of these results may be extended to nonorthogonal problems; for example, item 1 also applies to 2D output-sensitive convex hulls, item 3 applies to 3D convex hulls, and item 4 applies to general 2D line segment intersection and vertical decomposition of line segments. However, for nonorthogonal problems, the definition of a "comparison" needs to be extended to include testing of certain predicates (e.g., determining whether three points are in clockwise order), and we get into the delicate issue of whether just counting the number of predicate tests is meaningful, or whether