title: Implementing Delete a Node in Binary Search Tree
body: <p>Trying to delete a node from BST.  After the execution, the node still persists in the tree. How can I implement it properly?</p>
  
  <pre><code>public void deleteNode(TreeNode removeNode, TreeNode root)
  {
  
  
      if(removeNode.Left==null &amp;&amp; removeNode.Right==null) //0 children
      {
          removeNode = null;
      }
      else if(removeNode.Left==null)//1 children
      {
  
          removeNode = removeNode.Right;
      }
      else if(removeNode.Right==null)//1 children
      {
          removeNode = removeNode.Left;
      }
      else // 2 children
      {
          int successorValue = this.getSuccessor(removeNode, root);
          TreeNode successor = this.search(successorValue,root);
  
          removeNode.data = successor.data;
  
          deleteNode(successor, root);
      }
  
  }
  </code></pre>