Java icon indicating copy to clipboard operation
Java copied to clipboard

Added RandomizedClosestPair code and test

Open Jivi-this-side opened this issue 7 months ago • 3 comments

  • [x] I have read CONTRIBUTING.md.
  • [x] This pull request is all my own work -- I have not plagiarized it.
  • [x] All filenames are in PascalCase.
  • [x] All functions and variable names follow Java naming conventions.
  • [x] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • [ ] All new code is formatted with clang-format -i --style=file path/to/your/file.java

Randomized Closest Pair of Points : (As per issue #6219 added this algo to repo)

The Closest Pair of Points problem finds the minimum Euclidean distance between two points in a 2D plane.

Randomized Algorithm Approach:

  • Randomly shuffle the input points.

  • Use a sweep-line + grid bucketing strategy to maintain only nearby points for efficient lookup.

  • Continuously update the closest pair distance while sweeping from left to right.

⚡ Time Complexity

  • Expected Time: O(n)

  • Worst-case Time: O(n log n)

Use Cases

  • Geospatial clustering

  • Nearest-neighbor search

  • Computational geometry in games, simulations, and robotics

Thank you!

Jivi-this-side avatar Apr 17 '25 14:04 Jivi-this-side

Codecov Report

Attention: Patch coverage is 91.11111% with 4 lines in your changes missing coverage. Please review.

Project coverage is 73.85%. Comparing base (ad5e496) to head (f111af6).

Files with missing lines Patch % Lines
...healgorithms/randomized/RandomizedClosestPair.java 91.11% 3 Missing and 1 partial :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6224      +/-   ##
============================================
+ Coverage     73.81%   73.85%   +0.03%     
- Complexity     5311     5325      +14     
============================================
  Files           673      674       +1     
  Lines         18376    18421      +45     
  Branches       3553     3562       +9     
============================================
+ Hits          13565    13604      +39     
- Misses         4264     4267       +3     
- Partials        547      550       +3     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov-commenter avatar Apr 17 '25 14:04 codecov-commenter

So, how is it going? @Jivi-this-side

DenizAltunkapan avatar Apr 29 '25 21:04 DenizAltunkapan

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution!

github-actions[bot] avatar May 30 '25 00:05 github-actions[bot]

Please reopen this pull request once you have made the required changes. If you need help, feel free to ask in our Discord server or ping one of the maintainers here. Thank you for your contribution!

github-actions[bot] avatar Jun 06 '25 00:06 github-actions[bot]