Skip to content

Conversation

yadhu-vipin
Copy link

This PR fixes an issue in the ConvexHull class where the recursive method returned hull points in an unordered fashion due to the use of a HashSet. This caused algorithms that rely on vertex order, such as Rotating Calipers, to produce incorrect results (e.g., incorrect minimum bounding rectangle areas).

The fix preserves the counter-clockwise (CCW) order of the hull points while maintaining all points that lie on the convex polygon. This ensures compatibility with downstream geometric algorithms.

Changes:

  • Replaced HashSet with LinkedHashSet or List + sorting to preserve order.
  • Ensured deterministic CCW ordering starting from the bottom-most, left-most point.
  • Updated test expectations to match the ordered output.

Impact:

  • Algorithms like Rotating Calipers now compute correct values.
  • Maintains correctness for all convex hull computations.

@codecov-commenter
Copy link

codecov-commenter commented Oct 3, 2025

Codecov Report

❌ Patch coverage is 92.30769% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.65%. Comparing base (7e29be3) to head (0b40a35).

Files with missing lines Patch % Lines
...in/java/com/thealgorithms/geometry/ConvexHull.java 92.30% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6609      +/-   ##
============================================
- Coverage     75.68%   75.65%   -0.03%     
+ Complexity     5754     5738      -16     
============================================
  Files           699      699              
  Lines         19725    19697      -28     
  Branches       3826     3817       -9     
============================================
- Hits          14929    14902      -27     
+ Misses         4216     4215       -1     
  Partials        580      580              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@yadhu-vipin yadhu-vipin closed this Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants