Algorithm Analysis (CSC 301 2015F) : EBoards

CSC301.01 2015F, Class 15: 2-3 Trees


Overview

Preliminaries

Admin

Upcoming Work

Extra Credit

Academic

Peer

Questions

2-3 Trees

Insertion in 2-3 Trees

Idea 1: If we insert in the two-element left subtree of a singleton node, move the largest value in the left subtree up, and move the value in the right subtree down

Idea 2: Move the center value value up, split the node, and cross your fingers.

We will pursue idea 2

Example

          (8)
         /   \
      (2 5)  (17)

Insert 7

          (5 8)
         /  |  \
      (2)  (7)  (17)

Task

                (8   12)
              /    |    \
          (2 5)   (10)  (17)

Assume we insert 4

              (4  8   12)
              /    |    \
          (2) (5)   (10)  (17)

Pop the middle one up and split it

                (8)
              /    \
           (4)      (12)
          /   \     /   \
        (2)  (5)  (10)  (17)

Deletion in 2-3 Trees

                (8)
              /    \
           (4)      (12)
          /   \     /   \
        (2)  (5)  (10)  (17 21)

B-Trees

Generalized 2-3 trees min # values in a node and a maximum number (m-n)

Idea: The nodes in the tree are stored on disk, so we have 1K or more per node. We might as well make use of it. So ... array of values and links to other disk blocks