Question: solve tis question quickly please!! package tsp_brute; import java.util.*; public class TSP_Exh { static Scanner scan = new Scanner(System.in); // Number of nodes is known

solve tis question quickly please!! package tsp_brute; import java.util.*; public class TSP_Exh { static Scanner scan = new Scanner(System.in); // Number of nodes is known to be 5 static int n = 5; // TSP function public static Return tsp(int adjMat[][], boolean visited[], int curr, int remaining, int start, int curr_weight, String nodes) { // Base case where the recursion stops if(remaining == 0 || visited[curr] == true){ Return v = new Return(Integer.MAX_VALUE,""); return v; } // Check whether only 1 node is remaining and whether it is visited or not // Return the total sum and add the current node to path if yes otherwise return 0 if(remaining == 1 && visited[curr] == false){ if(adjMat[curr][start]>0){ String s = ""; s+=nodes.charAt(curr); Return r = new Return(curr_weight+adjMat[curr][start],s); return r; }else{ Return v = new Return(Integer.MAX_VALUE,""); return v; } } // Change the visited array to true to indicate current node has already been visited visited[curr] = true; // Use the recursion to find the next value Return res = new Return(Integer.MAX_VALUE,""); for(int i = 0; i < n; i++){ int curr_node = adjMat[curr][i]; if(curr_node > 0){ // Move to all possible nodes and pick the smallest possible answer Return resSmall = tsp(adjMat,visited,i,remaining-1,start,curr_weight+curr_node,nodes); res = res.res 

write the pseudocode for this java code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!