for val in [7,3,9,1,4]: bst.insert(val) other.insert(val) print("First contents: {}".format([val for val in bst])) print("Other contents: {}".format([val for val in other])) identical = bst.is_identical(other) print("Identical? {}".format(identical)) print("Expected: {}".format(True)) print("\n\nTesting BST#min") print("\n\nEmpty bst") bst = BST() print("Contents: {}".format([val for val in bst])) try: min_value = bst.min() except AssertionError: print("Cannot find min of empty bst, assertion thrown correctly.") print("\n\nNon-empty bst") bst = BST() for val in [7,3,5,2,4,9]: bst.insert(val) print("Contents: {}".format([val for val in bst])) min_value = bst.min() print("Returned min value: {}".format(min_value)) print("Expected: {}".format(2)) print("\n\nTesting BST#leaf_count") print("\n\nEmpty bst")
bst2.insert(4) bst2.insert(7) bst2.insert(2) bst2.insert(3) bst2.insert(1) empty = bst1.is_empty() print(empty) is_valid = bst1.is_valid() print(is_valid) is_identical = bst1.is_identical(bst2) print(is_identical) mini = bst1.min() print(mini) leaf_count = bst1.leaf_count() print(leaf_count) one_child_count = bst1.one_child_count() print(one_child_count) two_child_count = bst1.two_child_count() print(two_child_count) inorder = bst1.inorder() print(inorder) postorder = bst1.postorder()