Chapter 9: Search Trees II

9.3 Multi-Way Search Trees

Definition


Searching in a Multi-Way Tree


9.4 (2,4) Trees



9.4.1 Update Operations

Insertion


Algorithm insertItem(k, e)
1.We search for key k to locate the insertion node v
2.We add the new item (k, e) at node v
3. while overflow(v)
        if isRoot(v)
            create a new empty root above v
        vsplit(v)

Analysis of Insertion in a (2,4) Tree

Removal

  1. we merge v with an adjacent sibling w
  2. we move an item from u to the merged node v'
  • After a fusion, the underflow may propagate to the parent u

    1. we move a child of w to v
    2. we move an item from u to v
    3. we move an item from w to u
  • After a transfer, no underflow occurs


  • Analysis of Removal in a (2,4) Tree

    9.5 Red-Black Trees




    9.5.1 Update Operations

    Insertion


    • Case 1: w is black
      • The double red is an incorrect replacement of a 4-node
      • Restructuring: we change the 4-node replacement

    • Case 2: w is red
      • The double red corresponds to an overflow
      • Recoloring: we perform the equivalent of a split operation in (2,4)-tree




    Analysis of Insertion in a Red-Black Tree Removal


    Red-Black Tree Reorganization

    Insertion (remedy double red)
    Red-black tree action
    (2,4) tree action
    result
    restructuring change of 4-node representation
    double red removed
    recoloring
    split
    double red removed or propagated up

    Deletion (remedy double black)
    Red-black tree action
    (2,4) tree action result
    restructuring
    transfer
    double black removed
    recoloring
    fusion
    double black removed or propagated up
    adjustment
    change of 3-node representation
    restructuring or recoloring follows

    9.5.2 C++ Implementation
    html-9.11 (RBItem)
    html-9.12 (RBTree1)
    html-9.13 (RBTree2)
    html-9.14 (RBTree3)