From 8602f4206bd013de011b754ec860499ef7b02603 Mon Sep 17 00:00:00 2001 From: jxu <7989982+jxu@users.noreply.github.com> Date: Thu, 5 Jan 2023 22:52:21 -0500 Subject: [PATCH 1/2] Credit Shamos for nearest pair of points algorithm Resolves #969 --- src/geometry/nearest_points.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/geometry/nearest_points.md b/src/geometry/nearest_points.md index 0f5eb8ff3..d5d54b996 100644 --- a/src/geometry/nearest_points.md +++ b/src/geometry/nearest_points.md @@ -18,7 +18,7 @@ $$ \rho (p_i,p_j) = \sqrt{(x_i-x_j)^2 + (y_i-y_j)^2} .$$ The trivial algorithm - iterating over all pairs and calculating the distance for each — works in $O(n^2)$. -The algorithm running in time $O(n \log n)$ is described below. This algorithm was proposed by Preparata in 1975. Preparata and Shamos also showed that this algorithm is optimal in the decision tree model. +The algorithm running in time $O(n \log n)$ is described below. This algorithm was proposed by Shamos in 1975. (Source: Ch. 5 Notes of _Algorithm Design_ by Kleinberg & Tardos, see references) Preparata and Shamos also showed that this algorithm is optimal in the decision tree model. ## Algorithm We construct an algorithm according to the general scheme of **divide-and-conquer** algorithms: the algorithm is designed as a recursive function, to which we pass a set of points; this recursive function splits this set in half, calls itself recursively on each half, and then performs some operations to combine the answers. The operation of combining consist of detecting the cases when one point of the optimal solution fell into one half, and the other point into the other (in this case, recursive calls from each of the halves cannot detect this pair separately). The main difficulty, as always in case of divide and conquer algorithms, lies in the effective implementation of the merging stage. If a set of $n$ points is passed to the recursive function, then the merge stage should work no more than $O(n)$, then the asymptotics of the whole algorithm $T(n)$ will be found from the equation: From ee59360bf42c8105c647da48ee3c48091b78836a Mon Sep 17 00:00:00 2001 From: Oleksandr Kulkov Date: Sun, 29 Jan 2023 22:14:12 +0100 Subject: [PATCH 2/2] Shamos -> Shamos and Hoey --- src/geometry/nearest_points.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/geometry/nearest_points.md b/src/geometry/nearest_points.md index d5d54b996..4aab174d5 100644 --- a/src/geometry/nearest_points.md +++ b/src/geometry/nearest_points.md @@ -18,7 +18,7 @@ $$ \rho (p_i,p_j) = \sqrt{(x_i-x_j)^2 + (y_i-y_j)^2} .$$ The trivial algorithm - iterating over all pairs and calculating the distance for each — works in $O(n^2)$. -The algorithm running in time $O(n \log n)$ is described below. This algorithm was proposed by Shamos in 1975. (Source: Ch. 5 Notes of _Algorithm Design_ by Kleinberg & Tardos, see references) Preparata and Shamos also showed that this algorithm is optimal in the decision tree model. +The algorithm running in time $O(n \log n)$ is described below. This algorithm was proposed by Shamos and Hoey in 1975. (Source: Ch. 5 Notes of _Algorithm Design_ by Kleinberg & Tardos, also see [here](https://ieeexplore.ieee.org/abstract/document/4567872)) Preparata and Shamos also showed that this algorithm is optimal in the decision tree model. ## Algorithm We construct an algorithm according to the general scheme of **divide-and-conquer** algorithms: the algorithm is designed as a recursive function, to which we pass a set of points; this recursive function splits this set in half, calls itself recursively on each half, and then performs some operations to combine the answers. The operation of combining consist of detecting the cases when one point of the optimal solution fell into one half, and the other point into the other (in this case, recursive calls from each of the halves cannot detect this pair separately). The main difficulty, as always in case of divide and conquer algorithms, lies in the effective implementation of the merging stage. If a set of $n$ points is passed to the recursive function, then the merge stage should work no more than $O(n)$, then the asymptotics of the whole algorithm $T(n)$ will be found from the equation: