title: How to build a binary tree
body: <p>Does it work?
  decided to switch 678 and 1789 in the inOrder array, and that put 1789 to the left of 678, and a 0 to the right of 678. In the code below</p>
  
  <pre><code>public static BinaryTreeNode buildTree(int inOrder[], int preOrder[], int 
  preIndex )
  {               
  if (inOrder.length &gt; 1)  
  {
      int inIndex = 0;
      for (int i = 0; i &lt; inOrder.length; i++)
      {
          if (preOrder[preIndex] == inOrder[i])
          {
              inIndex = i ;
              break;                  
          }
      }
  
      if (inIndex &gt; 0)
      {          
          BinaryTreeNode node = new BinaryTreeNode(inOrder[inIndex]);
  
          if (preIndex &lt; preOrder.length - 1 )
          {
          node.setLeft(buildTree(leftArray(inOrder, inIndex), preOrder, preIndex + 1));
          node.setRight(buildTree(rightArray(inOrder, inIndex), preOrder, inIndex + 1));  
          }
  
          return node;
      }           
  }       
  return new BinaryTreeNode(inOrder[0]);
  </code></pre>
  
  <p>}</p>