Skip to content

Implement bitwise dp algorithm and sos dp - #7517

Open
narendrakumar9867 wants to merge 2 commits into
TheAlgorithms:masterfrom
narendrakumar9867:feat/bitwise-dp-sos-dp
Open

Implement bitwise dp algorithm and sos dp#7517
narendrakumar9867 wants to merge 2 commits 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

codecov-commenter commented Jul 8, 2026

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.23%. Comparing base (c498379) to head (d737776).
⚠️ Report is 29 commits behind head on master.

Files with missing linesPatch %Lines
...s/dynamicprogramming/TravelingSalesmanBitmask.java73.68%4 Missing and 6 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## master #7517 +/- ##
============================================
- Coverage 80.25% 80.23% -0.02% - Complexity 7358 7376 +18 
============================================
Files 810 811 +1 Lines 23787 23825 +38 Branches 4678 4693 +15 ============================================
+ Hits 19091 19117 +26 - Misses 3940 3944 +4 - 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.

@narendrakumar9867narendrakumar9867 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong id use

@narendrakumar9867

Copy link
Copy Markdown
Author

@DenizAltunkapan can you please look this pr?

@DenizAltunkapan

Copy link
Copy Markdown
Member

@narendrakumar9867 you need to fix the failing workflows (formatting) first otherwise i am not reviewing it

Sign up for freeto 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.

4 participants

@narendrakumar9867@codecov-commenter@DenizAltunkapan@narendrakumar-andlab