title: comparing two binary tree
body: <p>Basically this following code will check whether two different binary trees have the same members of integer. The way that I'm supposed to do it is to store the integer from tree to array and then compare the array.</p>
  
  <p>Here is the code that put the integers to array</p>
  
  <pre><code>private static int toarray (btNode t, int[] a, int i)
  {
      int num_nodes = 0;
      if (t != null)
      {
          num_nodes = toarray (t.left , a , i);
          a [num_nodes + i] = t.info;
          num_nodes = num_nodes + i + toarray (t.right,a,num_nodes + i + 1);
      }
      return num_nodes;
  }
  </code></pre>
  
  <p>Here is the code that check if the two trees are equal or not</p>
  
  <pre><code>public boolean equals(Intcoll6 obj)
  {
      boolean result = true;
      if (how_many == obj.how_many)
      {
          int[]a = new int [how_many];
          int[]b = new int [obj.how_many];
  
  
          toarray (c,a,0);
          toarray (obj.c,b,0);
  
  
          for (int j = 0; j &lt; how_many; j++)
          {
  
              if ( a[j] == (b[j]))
              {
                  result = true;
              }
              else
                  result = false;
          }
     }
     else
     {
          result = false;
     }
      return result;
  }
  </code></pre>
  
  <p>so far (for obvious reason) it only works if the length of tree are not equal. I can't really figure out what's wrong with the code, so any suggestions will help. Thanks in advance </p>