0

Let k and 2k be keys in a B-­tree, B. 

Assume that the depth of B is reduced if the key k is deleted. 

It is necessary the case that if we delete the key 2k instead, the depth of B will be reduced as well?

I'm having a hard time to visualize and solve this, can someone please show me how should I think about this and solve this?

user1326293
  • 923
  • 2
  • 9
  • 24

1 Answers1

1

Assuming a classical B-tree that constrains the number of keys per node: a precondition for a node merge involving the root - and thus a reduction in height - is that the root have exactly one key and exactly two children, both of which have exactly the minimum allowable number of keys. The state of affairs at deeper levels of the tree does not matter.

If the top of the tree looks as described, then the height reduction can be triggered by deleting the root's only key or one of the keys in its two children. That deletion could be direct, or it could be the result of a change rippling up after a deletion deeper in the tree.

In any case there are many constellations where deletion of key 2k will not trigger a height reduction under the same circumstances. There are many conditions that can prevent a height reduction after the deletion of key 2k: the key residing in a 'safe' node (with more than the minimum number of keys) or having a 'safe' parent, the existence of 'safe' siblings somewhere along the path so that borrowing becomes possible, etc. pp.

Visualisation resources on the web are discussed in another topic here:

Community
  • 1
  • 1
DarthGizka
  • 4,347
  • 1
  • 24
  • 36