title: Deletion in B Plus Tree Korth Pseucode
body: <p>The pseudo code given in the Database Systems Concept by Korth is the following.
  <a href="https://i.stack.imgur.com/ZY6s2.png" rel="nofollow noreferrer">Pseucode</a></p>
  
  <p>Consider that we have the following tree with order = 5</p>
  
  <pre><code>                         [7.0]
         [3.0, 5.0]                      [9.0, 11.0, 13.0]
   &lt;Lead Nodes Here&gt;                       &lt;Lead Nodes Here&gt;
  </code></pre>
  
  <p>Now image that we are at level 2 and in the function delete_entry([3.0, 5.0], 3.0, Pointer to Child). Now as per the algorithm we delete 3.0, so now we are left with [5.0] and [9.0, 11.0, 13.0]. Looking at the first marked if condition we see that these nodes can be merged as (1+3) &lt;= (order - 1) therefore 4 keys can fit in one node. But since they are not a leaf node therefore the second marked line in the code will execute and apart from merging these two nodes it will also insert 7 in them. Therefore giving us a node with number of keys = 5, which violates the condition that number of keys in non leaf node should be &lt;= order -1.</p>
  
  <p>Am I doing something wrong here?</p>