0

Troubleshooting Java Code for Travelling Salesman Problem

Hello, I'm having trouble getting my Java code to solve the Travelling Salesman Problem. I'm following a TSP tutorial from here: https://www.interviewbit.com/blog/travelling-salesman-problem/ that uses the following code: // Initialize the matrix int[][] d = new int[][] { { 0, 10, 15, 20 }, { 10, 0, 35, 25 }, { 15, 35, 0, 30 }, { 20, 25, 30, 0 } }; // Initialize the array of visited cities boolean[] visited = new boolean[] { false, false, false, false }; // Initialize the current path int[] path = new int[4]; // Initialize minPathLength int minPathLength = Integer.MAX_VALUE; // Call the search method search(d, visited, 0, 0, 4, path, minPathLength); However, when I try to run the code, I get an error. Is there an issue with my code or is there something else I am missing? Any help would be greatly appreciated. Thanks in advance!

25th Apr 2023, 10:15 AM
RiddhmiaRaO
RiddhmiaRaO - avatar
2 Antworten
+ 4
Perhaps the following guide with help: https://code.sololearn.com/Wek0V1MyIR2r/?ref=app
25th Apr 2023, 1:10 PM
Ausgrindtube
Ausgrindtube - avatar
+ 8
Alisha Singh please share code
25th Apr 2023, 10:15 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar