title: question about binary search tree-insert value to binary search tree
body: <p>I have a question about my homework, I need to insert value to the tree but is not insert correctly.</p>
  
  <p><strong>This my question:</strong> Complete the following method which inserts a new node containing the value data into the binary search tree pointed to by the parameter treePtr. It should insert the data so that the resulting tree is still a binary search tree and return a pointer to the root node. Note that the tree might be empty to start with (that is, the value of the parameter treePtr might be null).  </p>
  
  <p><strong>This is my code:</strong></p>
  
  <pre><code>public static TreeNode insertValue(TreeNode treePtr, int data) {
  
  if (treePtr == null) {
              return new TreeNode(data, null, null);
          }
  
          if (treePtr != null) {
             new TreeNode(treePtr.data, null, null);
          }
  
          if (treePtr.data&gt; data) {
              return insertValue(new TreeNode(data, null,treePtr ), data);
          }
          if (treePtr.data &lt; data) {
                        return insertValue(new TreeNode(data, treePtr ,null), data);
  
  }
          return treePtr;
  </code></pre>
  
  <p><strong>This is the answer that I received:</strong></p>
  
  <pre><code>The tree for example:
     (- 632 (- 725 -))
  After inserting 725, the tree should be:
     (- 632 (- 725 -))
  Your solution produced this:
     ((- 632 -) 725 -)
  </code></pre>
  
  <p>I need help with this question.</p>
  
  <p>Thank you, everyone.</p>