コード例 #1
0
ファイル: test_AVLTree.py プロジェクト: ekurz20/trees
def test__AVLTree_is_avl_satisified8():
    avl = AVLTree()
    avl.root = Node(0)
    avl.root.left = Node(-2)
    avl.root.left.left = Node(-3)
    avl.root.left.left.left = Node(-4)
    avl.root.left.right = Node(-1)
    avl.root.right = Node(2)
    avl.root.right.left = Node(1)
    avl.root.right.right = Node(3)
    avl.root.right.right.right = Node(4)
    avl.root.right.right.right.right = Node(5)
    assert avl.is_bst_satisfied()
    assert not avl.is_avl_satisfied()
コード例 #2
0
ファイル: test_AVLTree.py プロジェクト: ekurz20/trees
def test__AVLTree_remove1(xs):
    '''
    This tests the remove function.
    In order to test the remove function, we must be able to generate valid AVLTrees.
    Therefore, you must have all the insert functionality completed before this test can pass.
    '''
    random.seed(0)
    xs = list(set(xs))
    avl = AVLTree(xs)
    while len(xs) > 0:
        x = random.choice(xs)
        xs.remove(x)
        assert x in avl
        avl.remove(x)
        assert x not in avl
        assert set(avl.to_list('inorder')) == set(xs)
        assert avl.is_avl_satisfied()
コード例 #3
0
ファイル: test_AVLTree.py プロジェクト: yismaeel21/trees
def test__AVLTree___init__(xs):
    xs = list(set(xs))
    avl = AVLTree(xs)
    assert avl.is_bst_satisfied()
    assert avl.is_avl_satisfied()
コード例 #4
0
ファイル: test_AVLTree.py プロジェクト: yismaeel21/trees
def test__AVLTree_is_avl_satisified6():
    avl = AVLTree()
    avl.root = Node(0)
    avl.root.right = Node(1)
    assert avl.is_bst_satisfied()
    assert avl.is_avl_satisfied()
コード例 #5
0
ファイル: test_AVLTree.py プロジェクト: yismaeel21/trees
def test__AVLTree_is_avl_satisified4():
    avl = AVLTree()
    assert avl.is_bst_satisfied()
    assert avl.is_avl_satisfied()