Preview

Redistribution or Merging

Good Essays
Open Document
Open Document
634 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Redistribution or Merging
N: maximum number of keys per node.
D : node from which key is to be deleted.

L : left sibling of D

R: right sibling of D

After deleting key from leaf node D, if D contains less than ceil(N/2) keys ( i.e. underflow in D), then check the following cases. Redistribution or Merging

1) Redistribution for Leaf node

i) If L or R node contains ceil(N/2) + 1 or more keys then

a) Move the rightmost key from L to D in case of left sibling.

b) Move the leftmost key from R to D in case of right sibling.

ii) Then replace the parent key of these nodes with maximum key from L ( in case of L & D) or maximum key from D ( in case of D & R).

.

After deleting 10, we have

Redistribute and change the parent key.

NOTE: A key can appear at only one ancestor D( in the leaf)

After deleting key from D, replace the key (deletion key) in the internal node by the smallest key in D.

2) Merging

This case arises If the sibling L or R node contains exactly ceil (N/2) keys, then

a) If there are keys remaining in D, Move the key or keys from D to L or R.

b) Since D node is empty, remove the pointer from parent to D.

c) Delete the key between L or R and D from the parent node.

Deleting the key from internal node

Suppose we remove a key from internal node D and after deleting if D has less than ceil(N+1/2)-1 keys then choose any one of the following cases:

Case 1 (Redistribution):- If L or R has >= ceil(N+1/2) keys then,

a. Move the parent key between D and L or R down to D.

b. Make leftmost child of R as the rightmost child of D.

Or

Make rightmost child of L as the leftmost child of D.

c. Move the leftmost child (in case of R) or

You May Also Find These Documents Helpful

Related Topics