title: Understanding the Recursion of mergesort
body: <p>Most of the mergesort implementations I see are similar to this. intro to algorithms book along with online implentations I search for. My recursion chops don't go much further than messing with Fibonacci generation (which was simple enough) so maybe it's the multiple recursions blowing my mind, but I can't even step through the code and understand whats going on even before I even hit the merge function.</p>
  
  <p><em>How</em> is it stepping through this? Is there some strategy or reading I should undergo to better understand the process here?</p>
  
  <pre><code>void mergesort(int *a, int*b, int low, int high)
  {
      int pivot;
      if(low&lt;high)
      {
          pivot=(low+high)/2;
          mergesort(a,b,low,pivot);
          mergesort(a,b,pivot+1,high);
          merge(a,b,low,pivot,high);
      }
  }
  </code></pre>
  
  <p>and the merge(although frankly I'm mentally stuck before I even get to this part)</p>
  
  <pre><code>void merge(int *a, int *b, int low, int pivot, int high)
  {
      int h,i,j,k;
      h=low;
      i=low;
      j=pivot+1;
  
      while((h&lt;=pivot)&amp;&amp;(j&lt;=high))
      {
          if(a[h]&lt;=a[j])
          {
              b[i]=a[h];
              h++;
          }
          else
          {
              b[i]=a[j];
              j++;
          }
          i++;
      }
      if(h&gt;pivot)
      {
          for(k=j; k&lt;=high; k++)
          {
              b[i]=a[k];
              i++;
          }
      }
      else
      {
          for(k=h; k&lt;=pivot; k++)
          {
              b[i]=a[k];
              i++;
          }
      }
      for(k=low; k&lt;=high; k++) a[k]=b[k];
  }
  </code></pre>