def test_balance_4_nodes_delete(): tree = Bst() for i in [3, 1, 0, 2]: tree.insert(i) assert tree.balance() in [-1, 0, 1] tree.delete(0) assert tree.balance() in [-1, 0, 1]
def test_balance_6_nodes_insert(tree_list): tree = Bst() for i in tree_list: tree.insert(i) assert tree.balance() in [-1, 0, 1] for i in range(5): tree.delete(i) assert not tree.contains(i) assert tree.balance() in [-1, 0, 1]
def test_balance_3_nodes_delete(tree_list): tree = Bst() for i in tree_list: tree.insert(i) for i in range(3): tree.delete(i) assert tree.balance() in [1, 0, -1]
def test_balance_6_nodes_insert(tree_list): tree = Bst() for i in tree_list: tree.insert(i) assert tree.balance() in [-1, 0, 1]