title: Reversing a linkedlist recursively in c
body: <p>The following code works fine when head is sent as a parameter to it. As I am new to C, I couldn't understand how it works. Help me out please.</p>
  
  <pre><code>struct node *recursiveReverseLL(struct node *list)
  {
      struct node *revHead;
      if (list == NULL || list-&gt;link == NULL)
      {
          return list;
      }
  
      revHead = recursiveReverseLL(list-&gt;link);
      list-&gt;link-&gt;link = list;
      list-&gt;link = NULL; 
  
      return revHead;
  }
  </code></pre>
  
  <p>I dont know how the links are provided using those recursive calls. ie) if the links are as,</p>
  
  <pre><code>1 -&gt; 2 -&gt; 3 -&gt; 4 
  </code></pre>
  
  <p>then hw is it changed as,</p>
  
  <pre><code>4 -&gt; 3 -&gt; 2 -&gt; 1
  </code></pre>