title: Binary Search Tree can't delete the root
body: <p>Everything is working fine in this function, but the problem is that I can't delete the root, I couldn't figure out what's the bug here.I've traced the "else part" it works fine until the return, it returns the old value I don't know why. Plz Help!</p>
  
  <pre><code>node *removeNode(node *Root, int key) {
  
  node *tmp = new node;
  
  if(key &gt; Root-&gt;value)
      Root-&gt;right = removeNode(Root-&gt;right,key);
  
  else if(key &lt; Root-&gt;value)
      Root-&gt;left = removeNode(Root-&gt;left, key);
  
  else if(Root-&gt;left != NULL &amp;&amp; Root-&gt;right != NULL) {
      node *minNode = findNode(Root-&gt;right);
  
      Root-&gt;value = minNode-&gt;value;
  
      Root-&gt;right = removeNode(Root-&gt;right,Root-&gt;value);
  }
  
  else {
      tmp = Root;
  
      if(Root-&gt;left == NULL)
          Root = Root-&gt;right;
      else if(Root-&gt;right == NULL)
          Root = Root-&gt;left;
  
      delete tmp;
  }
  
  return Root;
  
  }
  </code></pre>