Chapter 9: Search Trees II

9.3 Multi-Way Search Trees

Definition
24Trees.pdf 3, 4


Searching in a Multi-Way Tree
24Trees.pdf 5


9.4 (2,4) Trees

24Trees.pdf 5-7


9.4.1 Update Operations
Insertion
24Trees.pdf 8, 9


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
24Trees.pdf 10
Removal
24Trees.pdf 11-13

  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

    RedBlackTrees.pdf 3-5



    9.5.1 Update Operations
    Insertion
    RedBlackTrees.pdf 6-11


    • 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




    Analysis of Insertion in a Red-Black Tree
    Removal
    RedBlackTrees.pdf 12,13



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