Skip to content

Commit 937d47b

Browse files
authored
Update nearest_points.md - explanation of the implementation
1 parent fc76d12 commit 937d47b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/geometry/nearest_points.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ Finally, $\mathbb{E}[C(d)] = \mathbb{E}[\lambda(d) \, n] \le 4n$, and the expect
204204

205205
#### Implementation of the algorithm
206206

207-
The advantage of this algorithm is that it is straightforward to implement, but still has good performance in practise.
207+
The advantage of this algorithm is that it is straightforward to implement, but still has good performance in practise. We first sample $n$ distances and set $d$ as the minimum of the distances. Then we insert points into the "blocks" by using a hash table from 2D coordinates to a vector of points. Finally, just compute distances between same-block pairs and adjacent-block pairs. Hash table operations have $O(1)$ expected time cost, and therefore our algorithm retains the $O(n)$ expected time cost with an increased constant.
208208

209209
```{.cpp file=nearest_pair_randomized}
210210
using ll = long long;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy