Skip to content

Fix bugs and typo errors in closest_pair_of_points.py #14355

Closed
Roy027 wants to merge 2 commits intoTheAlgorithms:masterfrom
Roy027:master
Closed

Fix bugs and typo errors in closest_pair_of_points.py #14355
Roy027 wants to merge 2 commits intoTheAlgorithms:masterfrom
Roy027:master

Conversation

@Roy027
Copy link

@Roy027 Roy027 commented Mar 9, 2026

Describe your change:

  • Add an algorithm
  • Fix a bug or typo in an existing algorithm
  • Add or change doctests
  • Documentation change

Summary

This PR fixes several logic errors in divide_and_conquer/closest_pair_of_points.py.

The strip search loop previously skipped valid comparisons due to incorrect
loop bounds. The recursive call also passed an incorrect sorted list,
breaking the divide-and-conquer step of the algorithm.

The doctest for dis_between_closest_in_strip() previously expected 85,
which only occurred because the buggy implementation skipped valid point
comparisons. After fixing the logic, the correct result is 5.

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file.
  • All functions and variable names follow Python naming conventions.
  • All functions and variable names follow Python naming conventions. (Checked: Added type hints)
  • All functions have doctests that pass the automated testing.

@algorithms-keeper algorithms-keeper bot added enhancement This PR modified some existing files awaiting reviews This PR is ready to be reviewed tests are failing Do not merge until tests pass labels Mar 9, 2026
@Roy027
Copy link
Author

Roy027 commented Mar 9, 2026

sorry accidentally modified DIRECTORY.md but i have removed changes.

@Roy027 Roy027 force-pushed the master branch 6 times, most recently from 1ff7e50 to cb89ec4 Compare March 10, 2026 07:36
@Roy027 Roy027 closed this Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files tests are failing Do not merge until tests pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant