Skip to content

Implement bitwise dp algorithm and sos dp#7517

Open
narendrakumar9867 wants to merge 1 commit into
TheAlgorithms:masterfrom
narendrakumar9867:feat/bitwise-dp-sos-dp
Open

Implement bitwise dp algorithm and sos dp#7517
narendrakumar9867 wants to merge 1 commit into
TheAlgorithms:masterfrom
narendrakumar9867:feat/bitwise-dp-sos-dp

Conversation

@narendrakumar9867

Copy link
Copy Markdown

This PR adds a new bitmask dynamic programming solution for the Traveling Salesman Problem. It implements the classic Held-Karp subset DP approach for small graphs, with support for missing edges and overflow-safe cost accumulation.

What changed:

  • Added TravelingSalesmanBitmask.java file with a solve(int[][]) API that computes the minimum Hamiltonian cycle cost starting and ending at city 0.
  • Validates input shape and handles edge cases like empty matrices, single-city graphs, and disconnected graphs.

Added unit tests covering:

  • a standard 4-city example
  • empty input
  • single-node input
  • disconnected graphs
  • non-square matrix rejection

Testing:

Added JUnit tests for the new implementation

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.68421% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.24%. Comparing base (c498379) to head (763cbe4).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...s/dynamicprogramming/TravelingSalesmanBitmask.java 73.68% 4 Missing and 6 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7517      +/-   ##
============================================
- Coverage     80.25%   80.24%   -0.02%     
- Complexity     7358     7376      +18     
============================================
  Files           810      811       +1     
  Lines         23787    23825      +38     
  Branches       4678     4693      +15     
============================================
+ Hits          19091    19118      +27     
- Misses         3940     3943       +3     
- Partials        756      764       +8     

☔ View full report in Codecov by Harness.
📢 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.

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.

3 participants