static void __bst_insert(NODE** node, int data)
{
    if(*node == NULL) {
        *node = __bst_new_node(data, NULL, NULL);	
    } else {
        if(data == (*node)->data) {
            return;
        }
        else if(data <= (*node)->data) {
            __bst_insert( &((*node)->left), data);
        } else {
            __bst_insert( &((*node)->right), data);
        }			
    }
}
Exemplo n.º 2
0
	void insert(const key_type& key, const mapped_type& value) {
		rb_tree_node* node = __buy_node(key, value);
		__bst_insert(node);
		node->color = red;
		__rb_insert_fixup(node);
	}
/* A utility function to insert a created new node with given data in BST */
void binary_search_tree_insert(NODE** root, int value)
{
    __bst_insert(root, value);
}