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") bst = BST() print("Contents: {}".format([val for val in bst])) count = bst.leaf_count() print("Leaf count: {}".format(count)) print("Expected: {}".format(0)) print("\n\nNon-empty bst, 1 leaf") bst = BST() for val in [7]: bst.insert(val) print("Contents: {}".format([val for val in bst])) count = bst.leaf_count() print("Leaf count: {}".format(count)) print("Expected: {}".format(1)) print("\n\nNon-empty bst, more than 1 leaf") bst = BST() for val in [7,4,5,3,9,10,]:
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() print(postorder) levelorder = bst1.levelorder