title: How to reverse a singly linked list using only two pointers?
body: <p>I wonder if there exists some logic to reverse a singly-linked list using only two pointers.</p>
  
  <p>The following is used to reverse the single linked list using three pointers namely <code>p</code>, <code>q</code>, <code>r</code>:</p>
  
  <pre><code>struct node {
      int data;
      struct node *link;
  };
  
  void reverse() {
      struct node *p = first,
                  *q = NULL,
                  *r;
  
      while (p != NULL) {
          r = q;
          q = p;
          p = p-&gt;link;
          q-&gt;link = r;
      }
      first = q;
  }
  </code></pre>
  
  <p>Is there any other alternate to reverse the linked list?  What would be the best logic to reverse a singly linked list, in terms of time complexity?</p>