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 ...
Introduction: A Binary Search Tree or BST is a binary tree in which left child of every node contain child whose value is smaller than current node and right child will contain child whose value is greater than current node. Binary Search Tree Insertion: There are many cases which must be consider to run the program without any error. Function execute: Reursive function -> Node* push(data,current_node) Every function return node or subtree which contain node to be inserted We always start from root node Let us consider an example of inserting 40 in the given tree Case 1: When data < current_node->data Step 1: Compere 40 with current_node (here root)->data, 40<50 ...
Comments
Post a Comment