Insertion: Let we create 2-3 tree by inserting elements: 20, 30, 40, 50, 60, 10, 15, 70, 80 Insert 20,30: Now we insert these two element in a single node as it can hold 2 elements so, Insert 40: Node is already full so split the node In splitting: We take two nodes left and right and a root node Left node contain smallest element Right node contain greatest element Root node contain middle element and take lest and ...
Rotation is required only in the nodes which are imbalance, imbalance means that | height of right sub-tree - height of left sub-tree | > 1. Balancing reduce the height of tree like a tree with node n have maximum height (n-1) but after rotation it will be about log(n).
Comments
Post a Comment