Skip to content

Solved TravelingSalesManProblem Using DynamicProgramming(memoization) #5687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from

Conversation

Sujal1804
Copy link

In the above code, we implement a solution to the Traveling Salesman Problem (TSP) using dynamic programming with memoization. The algorithm calculates the shortest possible route that visits a set of cities exactly once and returns to the starting city by recursively exploring all possible paths and storing the results of subproblems to avoid redundant calculations. The program outputs both the minimum cost of the tour and the optimal path taken.

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

In the above code, we implement a solution to the Traveling Salesman Problem (TSP) using dynamic programming with memoization. The algorithm calculates the shortest possible route that visits a set of cities exactly once and returns to the starting city by recursively exploring all possible paths and storing the results of subproblems to avoid redundant calculations. The program outputs both the minimum cost of the tour and the optimal path taken.
@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.73%. Comparing base (bae7f89) to head (3a0caee).
Report is 33 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5687      +/-   ##
============================================
+ Coverage     64.10%   66.73%   +2.63%     
- Complexity     4195     4484     +289     
============================================
  Files           586      608      +22     
  Lines         16372    16913     +541     
  Branches       3158     3264     +106     
============================================
+ Hits          10495    11287     +792     
+ Misses         5448     5180     -268     
- Partials        429      446      +17     

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

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

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

Please remove main and add JUnit tests

@Sujal1804
Copy link
Author

Hi I have made the changes mentioned by you pls accept the changes

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

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

See https://github.com/TheAlgorithms/Java/tree/master/src/test/java/com/thealgorithms for test examples, they must be in a different place and with .java file extension

removed test and put in seperate file
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution!

@github-actions github-actions bot added the stale label Nov 16, 2024
Copy link

Please reopen this pull request once you have made the required changes. If you need help, feel free to ask in our Discord server or ping one of the maintainers here. Thank you for your contribution!

@github-actions github-actions bot closed this Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants