Esempio n. 1
0
def test_return_postorder_traversal():
    bst = BinarySearchTree()
    bst.add(3)
    bst.add(2)
    bst.add(6)
    actual = bst.post_order()
    expected = [2, 6, 3]
    assert actual == expected
Esempio n. 2
0
def test_return_inorder_traversal():
    bst = BinarySearchTree()
    bst.add(3)
    bst.add(2)
    bst.add(6)
    actual = bst.in_order()
    expected = [2, 3, 6]
    assert actual == expected
Esempio n. 3
0
def test_return_preorder_traversal():
    bst = BinarySearchTree()
    bst.add(3)
    bst.add(2)
    bst.add(6)
    actual = bst.pre_order()
    expected = [3, 2, 6]
    assert actual == expected
Esempio n. 4
0
def test_add_to_right():
    bst = BinarySearchTree()
    bst.add(3)
    bst.add(2)
    bst.add(6)
    assert bst.root.right.value == 6
Esempio n. 5
0
def test_instantiate_single_root():
    bst = BinarySearchTree()
    bst.add(1)
    assert bst.root.value == 1