title: How Do I Empty a Subtree in a Binary Tree in C?
body: <p>Currently when I call this function, it deletes all child nodes and frees the memory of the node I passed it, but the node is still linked to it's parent and contains garbage.<br/>
  I need to be able to set the parent node of the node I passed (either left or right child) equal to <code>NULL</code> so the program doesn't crash when traversing the tree.</p>
  
  <p>Here is the code I already have: </p>
  
  <pre class="lang-c prettyprint-override"><code>void emptySubtree(BinaryNode* node) {
      if (node == NULL)
          return;
  
      emptySubtree(node-&gt;left);
      emptySubtree(node-&gt;right);
      free(node);
  }
  </code></pre>
  
  <p>Here is my function call: <code>emptySubtree(tree-&gt;root-&gt;left)</code></p>