title: Error in finding two subsets having equal sum
body: <p>I have been trying to divide an array into two non empty disjoint subsets such that their sum are equal.  </p>
  
  <pre><code>eg. A = {1,2,3,6,88,55,29}  
  one possible answer = 1+2+3  and 6  
  </code></pre>
  
  <p>I have read mit tutorial on balanced partition problem but my constraints are different. I don't have to consider whole of set A(means its not necessary that A1 U A2 would result in A). Also another problem is limit of N. There are at most 100 distinct elements each (&lt;= 100 ) .<br>
  I have also read  <a href="https://stackoverflow.com/questions/525559/equal-sum-subsets-hybrid"><em>THIS</em></a>  post related to my problem, <em>but I couldn't get anything</em> .  </p>
  
  <pre><code>My present Algo -- 
  p[1][a[0]] = 1
  for i = 2 to n
     for j = 0 to n*n
       if( p[i][j] &gt;= 2) stop
  
              p[i][j] += j - a[i] &gt; 0 ? ( p[i-1][j] + p[i-1][j-a[i]] ):0
              p[i][j] += j == a[i] ? 1:0
              p[i][j] += j &lt; a[i] ? p[i-1][j]:0  
  </code></pre>
  
  <p>explanation :</p>
  
  <pre><code>Search for sum j at position i. If we got count at position j &gt;=2 means 
  there are more than two possibilities for summing up to j. 
  </code></pre>
  
  <p><a href="http://ideone.com/Ab02d#" rel="nofollow noreferrer">HERE is sample working code by me</a>  </p>
  
  <p>I know this method cant take care of disjoint sets but I am unable to figure out any other approach.  </p>
  
  <p>I am in learning phase of Dynamic Prog. and I find it somewhat difficult. Can someone please help me in finding out the error in my current algorithm. </p>