Page 551 Exercise 17


The modification of the insertb algorithm consists of these lines from Program 11. 2:

/* node p has to be split*/
Let p and q be defined as in Eq. (11.5);

With the following lines:

Let Parent = p's parent
Let Ki = the key in Parent which points to P
Let q = p's right sibling
If q→n ≤ m-1 then begin
/*the right child has space so shift entries*/
      Insert Ki into the appropriate place in q
      Insert x into Ki
      Output(p,q,parent) to disk
      Exit
end
else begin
/*use the splitting technique of Bayer &McCreight*/
    Insert p's keys into the array Key in sorted order
   Insert Ki into the array Key in sorted order
   Insert x into the array Key in sorted order
   Insert q's keys into the array Key in sorted order
   Insert Key(s) 1 .. (2m-2)/3) into p

   Insert Key (2m+1)/3 into Ki

   Insert Key(s)  m .. (m + (2m-2)/3 -1) into q
    
   Insert Key (2m - 2m/2 ) into Ki+1

   Insert Key(s) (2m - 2m/3 +1) .. 2m into R

   Set p→n to (2m-2)/3

   Set q→n to (2m-1)/3

   Set r→n to 2m/3
           
   Set Parent→n to Parent→n+1

   Set (2m-2)/3 +1 .. m-1 key values in p to void and pointers to NULL
   Set q's (2m-1)/3 +1 .. m-1 key values to void and pointers to NULL
   Set r's 2m/3 +1 ... m-1 key values and pointers to nil
   Output(Parent,p,q,r) to disk
   exit

end