def test_easy_delete2(): root = BSTreeNode(4) tree = BSTree() tree.add_node(root) values = [3, 5] [tree.add_node(BSTreeNode(_)) for _ in values] expected_results = [(4, 0, None), (3, 1, "left_child")] node_5 = next(tree.search_for_key(5)) BSTreeNode.delete_node(node_5) actual_results = get_diagram_elements(root) assert expected_results == actual_results
def test_easy_delete2(): root = BSTreeNode(4) tree = BSTree() tree.add_node(root) values = [3, 5] [tree.add_node(BSTreeNode(_)) for _ in values] expected_results = [ (4, 0, None), (3, 1, "left_child") ] node_5 = next(tree.search_for_key(5)) BSTreeNode.delete_node(node_5) actual_results = get_diagram_elements(root) assert expected_results == actual_results
def delete_node(self, a_node): BSTreeNode.delete_node(a_node, self)