title: how to delete an entire sub-tree from a binary tree in java
body: <p>I wrote the following code but it doesn't work for nodes except the root node.</p>
  
  <pre><code>public Node deleteSubTree(Node root) {
      if(root == null) {
          return null;
      }
      root.left  =  deleteSubTree(root.left);
      root.right =  deleteSubTree(root.right);
              //System.out.print(" : deleting-"+root.data);
      root = null;
      return root;
  }
  </code></pre>
  
  <p>I am passing the node to be deleted as the argument. Could you please tell what is wrong with this code?</p>