Esempio n. 1
0
def test_find_right_minimum_returns_root_node_when_no_rights():
    root_node = BinaryTreeNode(5)
    child_node = BinaryTreeNode(3)
    tree = BinaryTree(root_node)
    tree.insert_node(child_node)
    result = tree.find_right_minimum(root_node)
    assert result == root_node
Esempio n. 2
0
def test_find_right_minimum_returns_right_minimum_in_shallow_example():
    root_node = BinaryTreeNode(5)
    left_node = BinaryTreeNode(3)
    right_node = BinaryTreeNode(7)
    tree = BinaryTree(root_node)
    tree.insert_node(left_node)
    tree.insert_node(right_node)
    result = tree.find_right_minimum(root_node)
    assert result == right_node
Esempio n. 3
0
def test_find_right_minimum_returns_right_minimum_in_deep_example():
    root_node = BinaryTreeNode(5)
    left_node = BinaryTreeNode(3)
    right_node = BinaryTreeNode(9)
    deep_right_right_node = BinaryTreeNode(8)
    deep_right_left_node = BinaryTreeNode(11)
    tree = BinaryTree(root_node)
    tree.insert_node(left_node)
    tree.insert_node(right_node)
    tree.insert_node(deep_right_left_node)
    tree.insert_node(deep_right_right_node)
    result = tree.find_right_minimum(root_node)
    assert result == deep_right_right_node