4.2-3 Treeยง

2-3+ Tree

See this link for examples of operations.

See this link for an interactive visualization.

2-3+ Tree Insert Rules

  1. If you have room in the node, add in the record.
    • You might need to update parent keys, but not parent structure
  2. If the node overflows, then split 1/2.
    • Promote the right node's first key value to the parent.
    • This can cause a cascade of splits.

2-3+ Tree Deletion Rules (1)

  1. If the node has enough records, simply remove this one.
    • Don't bother to adjust key values of parents
  2. If the node underflows, attempt to borrow from a sibling.
    • Do not borrow from cousins.
    • Borrowing will require update of keys in parents, but not parent structure.

2-3+ Tree Deletion Rules (2)

  1. If borrowing is impossible, then that means something has to change structurally.

    • If this is a leaf node, then it goes away (no records left). Which means a deletion from the parent.
    • If this is an internal node that lost a child, then it is down to one child that must be merged with a sibling.
    • At a minimum, this means adjustment to other key values up the tree.
    • It could cause a cascade of merges up the tree. In the limit, the root might go away, making the tree become one level shorter.

Special Considerations for Project 2