print("Postorder: {}".format(post)) print("\n\nNon-empty bst") bst = BST() for val in [7,15,4,6,5,2,3,1,18,14]: bst.insert(val) print("Contents: {}".format([val for val in bst])) post = bst.postorder() print("Postorder: {}".format(post)) print("\n\nTesting BST#levelorder") print("\n\nEmpty bst") bst = BST() print("Contents: {}".format([val for val in bst])) level = bst.levelorder() print("Levelorder: {}".format(level)) print("\n\nNon-empty bst") bst = BST() for val in [7,15,4,6,5,2,3,1,18,14]: bst.insert(val) print("Contents: {}".format([val for val in bst])) level = bst.levelorder() print("Levelorder: {}".format(level)) print("\n\nTesting BST#remove") print("\n\nEmpty bst") bst = BST() print("Contents: {}".format([val for val in bst]))
Author: Max Dann ID: 190274440 Email: [email protected] __updated__ = "2020-03-23" ------------------------------------------------------- """ from BST_linked import BST tree = BST() tree.insert(5) tree.insert(6) tree.insert(3) tree.insert(1) tree.insert(4) tree.insert(8) ''' print(tree.is_valid()) tree._root._right._value = 4 print(tree.is_valid()) ''' ''' tree2 = BST() for i in range(1,7): tree2.insert(i) ''' print(tree.levelorder()) tree.remove(3) print(tree.levelorder())