title: How to apply Backtracking in solving Travelling salesman problem?
body: <p>I've been trying to solve TSP using backtracking.</p>
  <p>The question is that I have to print the sequence of  cities which form part of the cycle with minimum cost and its cost.
  I don't know how I could save that sequence.</p>
  <p>Here is an example of the code I'm trying.</p>
  <pre><code>public void backTracking(int node, int k, int index) {
      int cost = 0;
      
      while (!isSolution() &amp;&amp; hasMoreChild(node)) { 
          solution[index] = node;
          int nextChild = getNextChild(node);
          cost += matrixAdy[node][nextChild];
          backTracking(nextChild, k + 1, index + 1);
          solution[index] = -1;
      }
  }
  
  
  public boolean isSolution() {
      int finalNode = solution[solution.length - 1];
      for (int adyNode : matrixAdy[finalNode]) {
          if (adyNode == start) return true;
      }
      return false;
  }
  </code></pre>