Exemplo n.º 1
0
def test_postorder():
    tree = BinaryTree()
    tree.root = Node(50)
    tree.root.left = Node(30)
    tree.root.right = Node(70)
    tree.root.left.left = Node(20)
    tree.root.left.right = Node(40)
    actual = tree.post_order()
    expected = [20, 40, 30, 70, 50]
    assert actual == expected
def test_tree_postorder():
    tree = BinaryTree()
    tree.root = Node(1)
    tree.root.left = Node(11)
    tree.root.right = Node(2)
    tree.root.left.left = Node(111)
    tree.root.left.right = Node(112)
    actual = tree.post_order()
    expected = [111, 112, 11, 2, 1]
    assert actual == expected