title: Subset sum implementation
body: <p>I am implementing the algorithm for subset sum :</p>
  
  <pre><code>SUBSET SUM(X[1 .. n], T ):
  if T = 0
  return T RUE
  else if T &lt; 0 or n = 0
  return FALSE
  else
  return SUBSET SUM(X[2 .. n], T ) ∨ SUBSET SUM(X[2 .. n], T − X[1])
  </code></pre>
  
  <p>Please help me out in how can I pass the reduced array X[2...n] when recursing ?</p>
  
  <p>This is the code I wrote and it causes a segmentation fault:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
      int subsetsum(int a[], int sum, int size)
      {
              if(sum==0)
              return 1;
              else if (sum&lt;0 || size &lt;0)
              return  0;
              else
              return (subsetsum(a+1 , sum, size-1) || subsetsum(a+1, sum - *a, size-1));
      }
      `
  
      int main(int argc, char **argv)
      {
              int a[]={2,4,1,3,5},x;
              x=subsetsum(a,6,5);
              printf("%d",x);
              return 0;
      }
  </code></pre>