Close
Close Window

DSA Coursenotes

Chapter 11 Week 13

Show Source |    | About   «  11.1. Indexing   ::   Contents   ::   12.1. B-Trees  »

11.2. 2-3 Trees

11.2.1. 2-3 Trees

11.2.1.1. 2-3 Tree

  • A 2-3 Tree has the following properties:
    1. A node contains one or two keys

    2. Every internal node has either two children (if it contains one key) or three children (if it contains two keys).

    3. All leaves are at the same level in the tree, so the tree is always height balanced.

  • The 2-3 Tree has a search tree property analogous to the BST.

11.2.1.2. 2-3 Tree Example

  • The advantage of the 2-3 Tree over the BST is that it can be updated at low cost.

Created with Raphaël 2.1.2
  1. 18
  2. 32
  1. 12
  1. 23
  2. 30
  1. 48
  1. 10
  1. 15
  1. 20
  2. 21
  1. 24
  1. 31
  1. 45
  2. 47
  1. 50
  2. 52

11.2.1.3. 2-3 Tree Insertion (1)

1 / 6 Settings
<<<>>>

Simple insert into the 2-3 tree. We want to insert the key 14 into the tree.

Created with Raphaël 2.1.2
  1. 18
  2. 32
  1. 12
  1. 23
  2. 30
  1. 48
  1. 10
  1. 15
  1. 20
  2. 21
  1. 24
  1. 31
  1. 45
  2. 47
  1. 50
  2. 52
Insert:
  1. 14
Proficient Saving... Error Saving
Server Error
Resubmit

11.2.1.4. 2-3 Tree Insertion (2)

1 / 9 Settings
<<<>>>

A simple node-splitting insert for a 2-3 tree. We want to insert the key 55 into the tree.

Created with Raphaël 2.1.2
  1. 18
  2. 32
  1. 12
  1. 23
  2. 30
  1. 48
  1. 10
  1. 15
  1. 20
  2. 21
  1. 24
  1. 31
  1. 45
  2. 47
  1. 50
  2. 52
Insert:
  1. 55
Proficient Saving... Error Saving
Server Error
Resubmit

11.2.1.5. 2-3 Tree Insertion (3)

1 / 14 Settings
<<<>>>

Example of inserting a record that causes the 2-3 tree root to split. We want to insert the key 19 into the tree.

Created with Raphaël 2.1.2
  1. 18
  2. 32
  1. 12
  1. 23
  2. 30
  1. 48
  1. 10
  1. 15
  1. 20
  2. 21
  1. 24
  1. 31
  1. 45
  2. 47
  1. 50
  2. 52
Insert:
Promote:
  1. 19
Proficient Saving... Error Saving
Server Error
Resubmit

   «  11.1. Indexing   ::   Contents   ::   12.1. B-Trees  »

nsf
Close Window