コード例 #1
0
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
コード例 #2
0
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
コード例 #3
0
 def delete_node(self, a_node):
     BSTreeNode.delete_node(a_node, self)