Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit937d47b

Browse files
authored
Update nearest_points.md - explanation of the implementation
1 parentfc76d12 commit937d47b

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 =longlong;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp