title: How do you delete the last node in a (min-) heap?
body: <p>I'm learning for an exam and currently I'm at heaps. I have understood how to delete a node from a heap but I could find a case where I cannot use the algorithm to delete.</p>
  
  <p>The problem is I want delete <code>15</code> which is a leaf and the last node of the min heap. When you delete a node in a heap, you are looking for the last node of the heap, replace it with the deletion node and check if the children of this node are greater than it.. then continue this recursively.</p>
  
  <p>For this reason (<code>15</code> is last element and has no children), I don't know how to delete it. </p>
  
  <pre><code>        1
       /     \
      9       6
     / \     /
   17  11   8
   /
  15
  </code></pre>
  
  <p>I would think that you can just delete it without doing anything else. You basically replace it by itself since the deletion node = last node..? So it looks like that:</p>
  
  <pre><code>        1
       /     \
      9       6
     / \     /
   17  11   8
  </code></pre>
  
  <p>I hope you can help  me, I really need to know that for my exam and I couldn't find anything about that case on the internet.</p>