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
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
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
def test_add_to_right(): bst = BinarySearchTree() bst.add(3) bst.add(2) bst.add(6) assert bst.root.right.value == 6
def test_instantiate_single_root(): bst = BinarySearchTree() bst.add(1) assert bst.root.value == 1