Exemplo n.º 1
0
def test_node_rebalance_right_left_balance():
    x = AVLTree()
    x.head_node = AVLNode()
    x.add(10)
    x.add(15)
    x.add(13)
    print x.to_string()
    assert x.head_node.balance is 0
Exemplo n.º 2
0
def test_node_rebalance_right_left_balance():
    x = AVLTree()
    x.head_node = AVLNode()
    x.add(10)
    x.add(15)
    x.add(13)
    print x.to_string()
    assert x.head_node.balance is 0
Exemplo n.º 3
0
def test_node_rebalance_right_right_structure():
    x = AVLTree()
    x.head_node = AVLNode()
    x.add(1)
    x.add(5)
    x.add(10)
    assert x.head_node.value is 5
    assert x.head_node.left_node.value is 1
    assert x.head_node.right_node.value is 10
Exemplo n.º 4
0
def test_node_rebalance_right_right_structure():
    x = AVLTree()
    x.head_node = AVLNode()
    x.add(1)
    x.add(5)
    x.add(10)
    assert x.head_node.value is 5
    assert x.head_node.left_node.value is 1
    assert x.head_node.right_node.value is 10
Exemplo n.º 5
0
def test_node_rebalance_right_left_structure():
    x = AVLTree()
    x.head_node = AVLNode()
    x.add(10)
    x.add(15)
    x.add(13)
    print x.to_string()
    assert x.head_node.value is 13
    assert x.head_node.left_node.value is 10
    assert x.head_node.right_node.value is 15
Exemplo n.º 6
0
def test_node_rebalance_right_left_structure():
    x = AVLTree()
    x.head_node = AVLNode()
    x.add(10)
    x.add(15)
    x.add(13)
    print x.to_string()
    assert x.head_node.value is 13
    assert x.head_node.left_node.value is 10
    assert x.head_node.right_node.value is 15
Exemplo n.º 7
0
def test_node_rebalance_right_right_depth():
    x = AVLTree()
    x.head_node = AVLNode()
    x.add(1)
    x.add(5)
    x.add(10)
    assert x.head_node.right_depth is 1
    assert x.head_node.left_depth is 1
    assert x.head_node.right_node.left_depth is 0
    assert x.head_node.right_node.right_depth is 0
    assert x.head_node.left_node.left_depth is 0
    assert x.head_node.left_node.right_depth is 0
Exemplo n.º 8
0
def test_node_rebalance_right_right_depth():
    x = AVLTree()
    x.head_node = AVLNode()
    x.add(1)
    x.add(5)
    x.add(10)
    assert x.head_node.right_depth is 1
    assert x.head_node.left_depth is 1
    assert x.head_node.right_node.left_depth is 0
    assert x.head_node.right_node.right_depth is 0
    assert x.head_node.left_node.left_depth is 0
    assert x.head_node.left_node.right_depth is 0
Exemplo n.º 9
0
def test_node_rebalance_right_left_depth():
    x = AVLTree()
    x.head_node = AVLNode()
    x.add(10)
    x.add(15)
    x.add(13)
    print x.to_string()
    assert x.head_node.right_depth is 1
    assert x.head_node.left_depth is 1
    assert x.head_node.right_node.left_depth is 0
    assert x.head_node.right_node.right_depth is 0
    assert x.head_node.left_node.left_depth is 0
    assert x.head_node.left_node.right_depth is 0
Exemplo n.º 10
0
def test_node_rebalance_right_left_depth():
    x = AVLTree()
    x.head_node = AVLNode()
    x.add(10)
    x.add(15)
    x.add(13)
    print x.to_string()
    assert x.head_node.right_depth is 1
    assert x.head_node.left_depth is 1
    assert x.head_node.right_node.left_depth is 0
    assert x.head_node.right_node.right_depth is 0
    assert x.head_node.left_node.left_depth is 0
    assert x.head_node.left_node.right_depth is 0