Abstract
Given a set of n points in the plane, and a parameter \(k\), we consider the problem of computing the minimum (perimeter or area) axis-aligned rectangle enclosing \(k\) points. We present the first near quadratic time algorithm for this problem, improving over the previous near-\(O(n^{5/2})\)-time algorithm by Kaplan et al. (25th European Symposium on Algorithms. Leibniz Int Proc Inform, vol. 87, # 52. Leibniz-Zent Inform, Wadern, 2017). We provide an almost matching conditional lower bound, under the assumption that \((\min ,+)\)-convolution cannot be solved in truly subquadratic time. Furthermore, we present a new reduction (for both perimeter and area) that can make the time bound sensitive to \(k\), giving near \(O(nk)\) time. We also present a near linear time \((1+\varepsilon )\)-approximation algorithm to the minimum area of the optimal rectangle containing \(k\) points. In addition, we study related problems including the 3-sided, arbitrarily oriented, weighted, and subset sum versions of the problem.
Similar content being viewed by others
Notes
We reserve the right, in the future, to use the \(\widetilde{O}\) to hide any other things we do not like.
If \(\sigma =\tau \), one of the four recursive calls is unnecessary.
This definition of laminar family of sets is somewhat non-standard.
References
Aggarwal, A., Imai, H., Katoh, N., Suri, S.: Finding \(k\) points with minimum diameter and related problems. J. Algorithms 12(1), 38–56 (1991)
Atanassov, R., Bose, P., Couture, M., Maheshwari, A., Morin, P., Paquette, M., Smid, M., Wuhrer, S.: Algorithms for optimal outlier removal. J. Discrete Algorithms 7(2), 239–248 (2009)
Backurs, A., Dikkala, N., Tzamos, Ch.: Tight hardness results for maximum weight rectangles. In: 43rd International Colloquium on Automata, Languages, and Programming. Leibniz Int. Proc. Inform., vol. 55, # 81. Leibniz-Zent. Inform., Wadern (2016)
Barba, L., Durocher, S., Fraser, R., Hurtado, F., Mehrabi, S., Mondal, D., Morrison, J., Skala, M., Wahid, M.A.: On \(k\)-enclosing objects in a coloured point set. In: 25th Canadian Conference on Computational Geometry (Waterloo 2013), # 35. Carleton University, Ottawa (2013). http://cccg.ca/proceedings/2013/papers/paper_35.pdf
Barbay, J., Chan, T.M., Navarro, G., Pérez-Lantero, P.: Maximum-weight planar boxes in \(O(n^2)\) time (and better). Inf. Process. Lett. 114(8), 437–445 (2014)
de Berg, M., Cabello, S., Cheong, O., Eppstein, D., Knauer, Ch.: Covering many points with a small-area box. J. Comput. Geom. 10(1), 207–222 (2019)
Bern, M.: Approximate closest-point queries in high dimensions. Inf. Process. Lett. 45(2), 95–99 (1993)
Bremner, D., Chan, T.M., Demaine, E.D., Erickson, J., Hurtado, F., Iacono, J., Langerman, S., Pătraşcu, M., Taslakian, P.: Necklaces, convolutions, and \(X+Y\). Algorithmica 69(2), 294–314 (2014)
Brodal, G.S., Fagerberg, R., Greve, M., López-Ortiz, A.: Online sorted range reporting. In: Algorithms and Computation (Honolulu 2009). Lecture Notes in Computer Science, vol. 5878, pp. 173–182. Springer, Berlin (2009)
Chan, T.M.: Approximate nearest neighbor queries revisited. Discrete Comput. Geom. 20(3), 359–373 (1998)
Chan, T.M.: Geometric applications of a randomized optimization technique. Discrete Comput. Geom. 22(4), 547–567 (1999)
Chan, T.M., Har-Peled, S.: Smallest \(k\)-enclosing rectangle revisited. In: 35th International Symposium on Computational Geometry. Leibniz Int. Proc. Inform., vol. 129, # 23. Leibniz-Zent. Inform., Wadern (2019)
Chan, T.M., Lewenstein, M.: Clustered integer 3SUM via additive combinatorics. In: 47th ACM Symposium on Theory of Computing, pp. 31–40. ACM, New York (2015)
Chan, T.M., Pătraşcu, M.: Counting inversions, offline orthogonal range counting, and related problems. In: 21st Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 161–173. SIAM, Philadelphia (2010)
Chan, T.M., Williams, R.: Deterministic APSP, orthogonal vectors, and more: quickly derandomizing Razborov–Smolensky. In: 27th Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 1246–1255. ACM, New York (2016)
Cygan, M., Mucha, M., Węgrzycki, K., Włodarczyk, M.: On problems equivalent to \((\min ,+)\)-convolution. In: 44th International Colloquium on Automata, Languages, and Programming. Leibniz Int. Proc. Inform., vol. 80, # 22. Leibniz-Zent. Inform., Wadern (2017)
Das, S., Goswami, P.P., Nandy, S.C.: Smallest \(k\)-point enclosing rectangle and square of arbitrary orientation. Inf. Process. Lett. 94(6), 259–266 (2005)
Datta, A., Lenhof, H.-P., Schwarz, Ch., Smid, M.: Static and dynamic algorithms for \(k\)-point clustering problems. J. Algorithms 19(3), 474–503 (1995)
Eppstein, D., Erickson, J.: Iterated nearest neighbors and finding minimal polytopes. Discrete Comput. Geom. 11(3), 321–350 (1994)
Gabow, H.N., Tarjan, R.E.: A linear-time algorithm for a special case of disjoint set union. J. Comput. Syst. Sci. 30(2), 209–221 (1985)
Har-Peled, S., Mazumdar, S.: Fast algorithms for computing the smallest \(k\)-enclosing circle. Algorithmica 41(3), 147–157 (2005)
Har-Peled, S., Sharir, M.: Relative \((p,\epsilon )\)-approximations in geometry. Discrete Comput. Geom. 45(3), 462–496 (2011)
Jørgensen, A., Larsen, K.G.: Range selection and median: tight cell probe lower bounds and adaptive data structures. In: 22nd Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 805–813. SIAM, Philadelphia (2011)
Kaplan, H., Roy, S., Sharir, M.: Finding axis-parallel rectangles of fixed perimeter of area containing the largest number of points. In: 25th European Symposium on Algorithms. Leibniz Int. Proc. Inform., vol. 87, # 52. Leibniz-Zent. Inform., Wadern (2017)
Matoušek, J.: Reporting points in halfspaces. Comput. Geom. 2(3), 169–186 (1992)
Pătraşcu, M.: Towards polynomial lower bounds for dynamic problems. In: 42nd ACM International Symposium on Theory of Computing, pp. 603–609. ACM, New York (2010)
Segal, M., Kedem, K.: Enclosing \(k\) points in the smallest axis parallel rectangle. Inf. Process. Lett. 65(2), 95–99 (1998)
Tarjan, R.E.: Efficiency of a good but not linear set union algorithm. J. Assoc. Comput. Mach. 22(2), 215–225 (1975)
Williams, R.: Faster all-pairs shortest paths via circuit complexity. In: 46th ACM Symposium on Theory of Computing, pp. 664–673. ACM, New York (2014)
Zhou, G.: Two-dimensional range successor in optimal time and almost linear space. Inf. Process. Lett. 116(2), 171–174 (2016)
Acknowledgements
Work on this paper by T.M.C. was partially supported by an NSF AF award CCF-1814026. Work by S.H. was partially supported by an NSF AF awards CCF-1907400 and CCF-1421231.
Author information
Authors and Affiliations
Corresponding author
Additional information
Editor in Charge: Kenneth Clarkson
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
A preliminary version of this paper appeared in SoCG 2019 [12].
Appendix A Shallow Cutting for Points and 3-Sided Rectangles
Appendix A Shallow Cutting for Points and 3-Sided Rectangles
Here, we prove a shallow cutting lemma due to Jørgensen and Larsen [23]—we provide the full details for the sake of completeness.
Let \(P\) be a set of n points in general position (i.e., no two points share x or y values), let \(\ell \) be a horizontal line below all the points of \(P\), and let k be a parameter. For simplicity of exposition we assume \(\ell \) is the x-axis. We generate \(m = O(n/k)\) subsets \(Q_1,\ldots , Q_m\) of \(P\), each of size O(k), such that for any axis-parallel rectangle \(R\) that has its bottom edge on \(\ell \), and contains at most k points of \(P\), its associated subset of \(P\) is contained in one of these subsets.
To this end, we sweep horizontally upward from \(\ell \). At any point in time, the x-range is going to be split into interior disjoint intervals (the two extreme ones are rays). For an interval \(I = [x_1,x_2]\), its weight at time t is \(n(I,t) = \left| { P(I,t) } \right| \bigr .\), where is the active set of points associated with I. As soon as the weight of some active interval J becomes 2k, say at time t, we stop the sweep and split J into two intervals, by picking a value \(m \in J\) between the kth rank and \((k+1)\)th rank x-coordinates of the points of \(P(I,t)\), and breaking I at m into two intervals. See Fig. 6. Let \(I^-, I^+\) be the two intervals adjacent to I just before this split. We store the point \(p_t = (m,t)\) into a set of splitting points \(S\). Let be the rectangle associated with this split point, and add the set \(P(I^- \cup I \cup I^+,t) = P\cap R(p_t)\) to the collection of subsets being computed.
For every two consecutive intervals J, K in the final partition in the end of the sweeping, we add the set \(P(I\cup J,+\infty )\) to the collection. Let \(\mathcal {F}\) be the resulting family of sets.
1.1 Analysis
Observe that every time we insert a point \(p\) into \(S\), we are splitting a set of 2k points into two sets of k points. Since there are n points overall, this can happen at most n/k times. This readily implies that \(\left| {\mathcal {F}} \right| \le 2 n/k\).
Lemma B.1
Let \(R\) be any rectangle having its bottom edge on \(\ell \) such that \(\left| {R\cap P} \right| < k\). Then, there exists a set \(Q\in \mathcal {F}\) such that \(R\cap P\subseteq Q\). Furthermore, each set of \(\mathcal {F}\) contains at most 6k points.
Proof
Let \(I_R\) be the projection of \(R\) onto the x-axis. Let I be the last active interval that contains \(I_R\). If I is one of the final intervals, then all the points in the I strip are contained in the set that corresponds to I and its adjacent neighbor, and the claim immediately holds.
So, let t be the critical time, where I was split, and let \(p\) be the splitting point. There are several possibilities.
- I.:
-
If \(p\notin R\), then \(R(p_t)\) contains \(R\)—indeed, \(R(p_t)\) x-axis extent contains I, which contains \(I_R\), see Fig. 7. Now, \(R\cap P\subseteq R(p_t) \cap P\) is in \(\mathcal {F}\), and the claim holds.
- II.:
-
If \(p\in R\), then consider the lowest point \(q\) (in the y-direction) of \(S\setminus \left\{ {p} \right\} \) such that its x-axis coordinate is in \(I_R\).
- II.i.:
-
If \(q\) does not exist, then \(I_R\) is contained in two consecutive final intervals, and the claim readily holds.
- II.ii.:
-
If \(q\in R\), then the rectangle \(R' = [x(p),x(q)] \times [0, t(q)] \subseteq R\) contains k points of \(P\) (since it is one of the sides of the split created by \(q\)—which contains exactly k points by construction), see Fig. 8. But it is a contradiction to the assumption that \(| R\cap P| < k\).
- II.iii.:
-
If \(q\notin R\) then when the upward sweep line hits \(q\), the interval \(I_R\) is contained in two consecutive intervals, where one of them is being split by \(q\), see Fig. 9. But then, \(R(q)\) is taller than \(R\), and it spans these two intervals. We conclude that \(R\subseteq R(q)\), which implies the claim.
As for the size, observe that a set in \(\mathcal {F}\) is the union of at most three active sets, and each of these active sets contains at most 2k points. We conclude that a set of \(\mathcal {F}\) contains at most 6k points.\(\square \)
The running time is dominated by O(n/k) queries, each of the following form: report the lowest O(k) points inside a given vertical slab. This is a generalization of range minimum queries, and known data structures [9] achieve O(k) query time after O(n) preprocessing time, assuming that the points are given in x-sorted order. The total construction time is \(O(k\cdot n/k)=O(n)\). We thus get the following.
Restatement of Lemma 2.4 [23] Given a set \(P\) of n points in the plane, lying above a horizontal line \(\ell \), and a parameter k, one can compute a family \(\mathcal {F}\) of at most \(2\lceil {n/k}\rceil \) subsets of \(P\), each of size at most 6k. The collection of sets can be computed in O(n) time if the x-coordinates have been pre-sorted. For any axis-aligned rectangle \(R\) with its bottom edge lying on \(\ell \), that contains less than k points of \(P\), we have \(P\cap R\subseteq Q\) for some \(Q\in \mathcal {F}\).
Rights and permissions
About this article
Cite this article
Chan, T.M., Har-Peled, S. Smallest k-Enclosing Rectangle Revisited. Discrete Comput Geom 66, 769–791 (2021). https://doi.org/10.1007/s00454-020-00239-3
Received:
Revised:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00454-020-00239-3