Commit e24be4e
committed
Fix bugs and typo errors in closest_pair_of_points.py
Summary
This pull request addresses critical logic errors and typos in the
closest_pair_of_points.py
algorithm. These fixes ensure the algorithm produces mathematically correct results and passes all automated tests.
Key Fixes:
Loop Logic Correction: In
dis_between_closest_in_strip
, the search loop was modified to correctly check all necessary pairs within the strip optimization.
Recursion Parameter Fix: Corrected a typo in
closest_pair_of_points_sqr
where the X-sorted list was not being correctly partitioned for recursive calls.
Doctest Alignment: Updated the doctest in
dis_between_closest_in_strip
from 85 to 5 to reflect the correct mathematical result after the logic fix. The previous expected value of 85 was a result of the bugged implementation.1 parent a7b1937 commit e24be4e
1 file changed
+3
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
0 commit comments