Ejemplo n.º 1
0
def test_breadth_first_binarytree():
    bt = BinaryTree()
    bt.root = Node(2)
    bt.root.left = Node(7)
    bt.root.right = Node(5)
    bt.root.left.left = Node(2)
    bt.root.left.right = Node(6)
    bt.root.right.right = Node(9)
    bt.root.left.right.left = Node(5)
    bt.root.left.right.right = Node(11)
    bt.root.right.right.left = Node(4)

    assert BinaryTree.breadth_first_traversal(bt) == [
        2, 7, 5, 2, 6, 9, 5, 11, 4
    ]
Ejemplo n.º 2
0
def test_breadth_first_binarytree_one_element():
    bt = BinaryTree()
    bt.root = Node(8)
    assert BinaryTree.breadth_first_traversal(bt) == [8]
Ejemplo n.º 3
0
def test_breadth_first_binarytree_empty():
    bt = BinaryTree()
    assert BinaryTree.breadth_first_traversal(bt) == None