Beispiel #1
0
def test_preorder():
    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.pre_order()
    expected = [50, 30, 20, 40, 70]
    assert actual == expected
def test_tree_preorder():
    tree = BinaryTree()
    tree.root = Node(1)
    tree.root.left = Node(11)
    tree.root.right = Node(111)
    tree.root.left.left = Node(1111)
    tree.root.left.right = Node(11111)
    actual = tree.pre_order()
    expected = [1, 11, 1111, 11111, 111]
    assert actual == expected