title: Recursive function in java to fill binary tree with dictionary
body: <p>im trying to write a recursive function in java where it takes an arraylist full of words in alphabetical order and fills up the tree as best it can. As far as I can tell, the problem im having is that java doesnt pass by reference, so in my recursive function, I never actually update where the trees left and right branches point, meaning the top of the tree never points to anything. Is there a better (working) way to do this? Am I missing the mark completely in my attempt to fill the tree in the first place?</p>
  
  <pre><code>public void saveNode(BinaryTreeNode parent, int left, int right)
  {
      int middle = (int) Math.ceil(((double)(right-left))/2.0);
      int curIndex;
      curIndex = middle+left;
  
      parent = new BinaryTreeNode(words.get(curIndex));
  
      if(middle != 1)
      {
          saveNode(parent.left, left, curIndex);
          saveNode(parent.right, curIndex, right);
      }
  }
  </code></pre>
  
  <p>PS: I'm relatively new to java </p>