Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Driver:
- insert the value into the tree;
- BTree:
- insert the value from root(find the right place to put the value from root to leaf);
- if the root splits
- create a new parent for the splitted old root;
- InternalNode:
- find the correct child for this value;
- insert this value to that child
- {
- if child is not full and hence, succesfully inserted
- return NULL;
- else child splitted(update internal node)
- {
- if internal node is not full
- insert the new child;
- else
- if left sibling is not full
- lookLeft(update parent if needed)
- else if right sibling is not full
- lookRight(update parent if needed)
- else
- {
- split
- maintain left right sibling, and parent-child relation
- return the new node after split
- }
- }
- }
- LeafNode:
- if Leaf is not full
- put the value to the right slot;
- //NOTE: if it is the first child of parent, keys[0] of its parent need to be updated
- else
- {
- if left sibling is not full
- lookLeft(update parent if needed)
- else if right sibling is not full
- lookRight(update parent if needed)
- else
- {
- split;
- maintain left right sibling, and parent-child relation;
- return the new Leaf after split so their parent could update itself;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement