# 1112 answer if the index entries are inserted in

This preview shows pages 10–12. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Exercises 11 c. function insert in leaf(value K , pointer P ) if (tree is empty) create an empty leaf node L , which is also the root else Find the last leaf node in the leaf nodes chain L if ( L has less than n 1 key values) then insert ( K , P ) at the ±rst available location in L else begin Create leaf node L 1 Set L . P n = L 1; Set K 1 = last value from page L insert in parent(1, L , K 1, L 1) insert ( K , P ) at the ±rst location in L 1 end function insert in parent(level l , pointer P , value K , pointer P 1) if (level l is empty) then begin Create an empty non-leaf node N , which is also the root insert( P , K , P 1) at the starting of the node N return else begin Find the right most node N at level l if ( N has less than n pointers) then insert( K , P 1) at the ±rst available location in N else begin Create a new non-leaf page N 1 insert ( P 1) at the starting of the node N insert in parent( l + 1, pointer N , value K , pointer N 1) end end The insert in leaf function is called for each of the value, pointer pairs in ascending order. Similar function can also be build for de- scending order. The search for the last leaf or non-leaf node at any level can be avoided by storing the current last page details in an array. The last node in each level might be less than half ±lled. To make
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page10 / 12

1112 Answer If the index entries are inserted in ascending...

This preview shows document pages 10 - 12. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online