title: Why recursion function comes before the swap-function here?
body: <p>I wonder about the recursion here in the rearrangement function, the recursion here is to sort the array by a given number(x), the small than-X elements sorted in the beginning &amp; the greater than-X sorted at the end of the array. but as you can see in the last two lines, is it important to put the recursion before swap? &amp; what happened if putting the recursion after the swap? does it must-to-do always to put the recursion before?</p>
  
  <pre><code>void rearrange(int a[], int n, int x) {
      if (n == 0)
          return;
      if (a[0] &lt;= x)
          rearrange(a + 1, n - 1, x);
      else {
          if (a[n - 1] &gt; x)
              rearrange(a, n - 1, x);
          else {
              rearrange(a + 1, n - 2, x);
              swap(a, a + n - 1);
          }
      }
  }
  </code></pre>