title: Swap kth position from start and end in a single traverse linked list
body: <p>I have come across the following implementation for swapping the kth position from start and end in a linked list in single traverse.</p>
  
  <pre><code>node *list;
  node *p, *q, *r;
  p = q = r = list;
  
  i = 1;
  
  while(p != NULL)
  {
      if(i != k)
      {
          q = q-&gt;next;
          i++;
      }//q will eventually point to kth node from starting
  
      if(i == k)
      {
          r = r-&gt;next
      }//r will eventually point to kth node from end
  
      p = p-&gt;next;
  
  }
  
   Swap q &amp; r elements
  </code></pre>
  
  <p>But I feel it's not the right implementation, could anyone look at it and verify if it's correct?</p>
  
  <p>If it's wrong, what changes would I have to make?</p>