2-3 Trees Algorithm
Introduction
 2-3 tree is a tree in which each internal node(non-leaf)
has either 2 or 3 children, and all leaves are at the same
level
Some Rules for 2-3 Trees
 A node may contain 1 or 2 keys
 All leaf nodes are at the same depth
 All non-leaf nodes (except the root) have either 1 key and
two subtrees, or 2 keys and three subtrees
 The only changes in depth are when the root splits or
underflows
Another Example of 2-3 Tree
The Advantages of the 2-3 Trees
 Even though searching a 2-3 tree is not more efficient
than searching a binary search tree, by allowing the node
of a 2-3 tree to have three children, a 2-3 tree might be
shorter than the shortest possible binary search tree.
 Maintaining the balance of a 2-3 tree is relatively simple
than maintaining the balance of a binary search tree .
Insertion
Insert 39
Insert 38
Insert 37
Deletion
 1.Locate node n, which contains item I
 2.If node n is not a leaf swap I with inorder successor
 deletion always begins at a leaf
 3.If leaf node n contains another item, just delete item I
Delete 70
Deleting70: swap 70 with inorder successor (80)
Deleting70: ... get rid of 70
Result… Now delete 100
Deleting 100
Result… Now lets delete 80
Deleting 80 ...
Deleting 80 ...
Deleting 80 ...
Result…

2 3 Trees Algorithm - Data Structure