def test_balance1(): tree = Bst() lst = [5, 3, 2, 4, 1, 0] for i in lst: tree.insert(i) assert list(tree.breadth_first()) == [3, 1, 5, 0, 2, 4] tree.delete(0) assert list(tree.breadth_first()) == [3, 1, 5, 2, 4] tree.delete(1) assert list(tree.breadth_first()) == [3, 2, 5, 4] tree.delete(2) assert not tree.contains(2)
def test_balance_3_nodes_insert(tree_list): tree = Bst() for i in tree_list: tree.insert(i) assert list(tree.breadth_first()) == [1, 0, 2]