Skip to content

Update geometry/nearest_points.md, adding a randomized algorithm explanation #1473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

izanbf1803
Copy link
Contributor

@izanbf1803 izanbf1803 commented Jun 24, 2025

The new explanation adds two randomized algorithms that have linear expected runtime. One of them being much simpler to implement and remember than the traditional divide and conquer algorithm, and improving its runtime efficiency. An implementation for the first one is provided. An image is included to clarify the strategy of the first randomized algorithm.

Explanation of randomized algorithms for closest pair of points.
@izanbf1803
Copy link
Contributor Author

@adamant-pwn Please someone check this PR!

@mhayter
Copy link
Contributor

mhayter commented Jun 28, 2025

Wow, this is a significant contribution !Thank you. I'll try to read this soon and give input.

@mhayter
Copy link
Contributor

mhayter commented Jun 28, 2025

Some of the math @jxu might be good at too in addition to @adamant-pwn.

Briefly, the last expressions are not rendering properly. That might be a spacing issue:

$$O(n + \sum_{i=1}^{n} i \Pr(X_i = 1)) \le O(n + \sum_{i=1}^{n} i \frac{2}{i}) = O(3n) = O(n) \quad \quad \blacksquare $$

Lol it works in GitHub haha.

Quick edits. Rendering
@mhayter
Copy link
Contributor

mhayter commented Jun 28, 2025

Given the complexity, it may make sense to add basic tests to our suite.

Personally, I'd prefer proofs to be in one of those drop downs as I'm not as mathematically inclined and am likely to skip over it unless I'm really interested.

It's probably prudent to include the worst case time and scenarios in which they fail expectation.

The math claims will likely require hours to really sit down and verify for me but I'm hoping some of the other guys can chime in.

PS I'm not sure if we've standardized the site as American English or British English spellings ( I noticed practise vs practice.)

@izanbf1803
Copy link
Contributor Author

izanbf1803 commented Jun 28, 2025

Thanks for the useful changes @mhayter !!! I think I fixed the issue with the equation, block equations need to be surrounded by newlines apparently. How could this thing of having a dropdown for the proof be implemented? (EDIT: done!)

@mhayter
Copy link
Contributor

mhayter commented Jun 28, 2025

The current code does not compile: candidate_closest does not exist.

Also, I'd consider accepting references in the dist function and also changing the name of dis generator as it looks very similar.

@izanbf1803
Copy link
Contributor Author

Done @mhayter! Thanks for detecting the mistake.

Copy link
Member

@adamant-pwn adamant-pwn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the pull request! I think it's a very nice addition. I left some comments and suggestions, I hope we can merge this once they are resolved.

@izanbf1803
Copy link
Contributor Author

Thanks @adamant-pwn !!! Very useful feedback. I will try to find some time to solve the issues in the upcoming weeks.

izanbf1803 and others added 3 commits August 23, 2025 15:26
Better formatting

Co-authored-by: Oleksandr Kulkov <adamant.pwn@gmail.com>
Replace "cube" with "square"

Co-authored-by: Oleksandr Kulkov <adamant.pwn@gmail.com>
Better formatting

Co-authored-by: Oleksandr Kulkov <adamant.pwn@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants