Esempio n. 1
0
    def insert(self, key):
        """ Insert key in the tree maintaining the Red-Black invariants.

        Insert using the default BST insert method and color the node in RED.

        Args:
            key: int, the value of the inserted node.
        """
        inserted_node = BST.insert(self, key)
        inserted_node.append(RED)

        self.insert_case_1(inserted_node)
Esempio n. 2
0
    def insert(self, key):
        """ Insert key in the tree maintaining the Red-Black invariants.

        Insert using the default BST insert method and color the node in RED.

        Args:
            key: int, the value of the inserted node.
        """
        inserted_node = BST.insert(self, key)
        inserted_node.append(RED)

        self.insert_case_1(inserted_node)
Esempio n. 3
0
    def insert(self, key):
        """ Insert a node into the data structure.

        Args:
            key: int, the value to insert in the tree.

        Returns:
            A list representing the newly inserted node. Format:

        """
        node = BST.insert(self, key)
        self.reballance(node)
        return node
Esempio n. 4
0
 def insert(self, key):
     """ After regular BST insert, the new node is hoisted to the root. """
     node = BST.insert(self, key)
     return self.splay(node)
Esempio n. 5
0
 def insert(self, key):
     """ After regular BST insert, the new node is hoisted to the root. """
     node = BST.insert(self, key)
     return self.splay(node)