Example #1
0
def test_pre_order():
    tree = BST(3)
    tree.add(1)
    tree.add(4)
    actual = tree.print_tree("pre_order")
    expected = '3-1-4-'
    assert actual == expected
Example #2
0
def test_post_order():
    tree = BST(7)
    tree.add(4)
    tree.add(3)
    tree.add(2)
    tree.add(5)
    tree.add(9)
    tree.add(10)
    assert tree.print_tree('post_order') == '2-3-5-4-10-9-7-'
Example #3
0
def test_breadth_first_bst():
    tree = BST(7)
    tree.add(4)
    tree.add(3)
    tree.add(2)
    tree.add(5)
    tree.add(9)
    tree.add(10)
    assert tree.print_tree('breadth_first') == '7-4-9-3-5-10-2-'
Example #4
0
def test_in_order():
    tree = BST(7)
    tree.add(4)
    tree.add(3)
    tree.add(2)
    tree.add(5)
    tree.add(9)
    tree.add(10)
    assert tree.print_tree('in_order') == '2-3-4-5-7-9-10-'