Beispiel #1
0
def test_is_equal_tree_with_branch():
    x = RedBlackTreeNode(val=1)
    y = RedBlackTreeNode(val=3)
    x.left = RedBlackTreeNode(val=0)
    x.right = y
    y.parent = x
    y.left = RedBlackTreeNode(val=2)
    y.right = RedBlackTreeNode(val=4)
    assert is_equal_tree(x, y) == False
Beispiel #2
0
def test_right_rotate_not_from_root():
    tree3 = getTree3()
    tree4 = getTree4()
    tree4._right_rotate(tree4.root.left)
    assert is_equal_tree(tree3.root, tree4.root)
Beispiel #3
0
def test_right_rotate():
    tree1 = getTree1()
    tree2 = getTree2()
    tree2._right_rotate(tree2.root)
    assert is_equal_tree(tree1.root, tree2.root)
Beispiel #4
0
def test_is_equal_tree_nil():
    assert is_equal_tree(RedBlackTreeNode(), RedBlackTreeNode())
Beispiel #5
0
def test_is_equal_tree():
    x = RedBlackTreeNode(val=1)
    y = RedBlackTreeNode(val=1)
    assert is_equal_tree(x, y) == True