title: Recursive code for reversing a linked list is not working properly
body: <p>Here tail is a pointer to the last element of linked list.
  This code only works when there are odd numbers of nodes in a linked list and shows wrong output for even number of nodes. Please help what is the problem in the code and reason why it is happening?</p>
  <pre><code> public static class Node
   {
      int data;
      Node next;
    }
  
    public static class LinkedList
    {
      Node head;
      Node tail;
      int size;
      // many other member functions
      
      private void reversePRHelper(Node node , Node prev)
      {
        if(node == null)
        {
          return;
        }
        Node Next = node.next;
        node.next = prev;
        prev = node;
        reversePRHelper(Next , prev);
        
        Node temp = this.head;
        this.head = this.tail;
        this.tail = temp;
        
      }
      public void reversePR()
      {
        reversePRHelper(head,null);
      }
  }
    
  </code></pre>