예제 #1
0
 def test_items_post_order_with_7_numbers(self):
     # Create a complete binary search tree of 7 items in level-order
     items = [4, 2, 6, 1, 3, 5, 7]
     tree = BinarySearchTree(items)
     # Ensure the post-order traversal of tree items is ordered correctly
     assert tree.items_post_order() == [1, 3, 2, 5, 7, 6, 4]
 def test_items_post_order(self):
     # Create a complete binary search tree of 7 items in level-order
     items = [4, 2, 6, 1, 3, 5, 7]
     bst = BinarySearchTree(items)
     assert bst.items_post_order() == [1, 3, 2, 5, 7, 6, 4]
예제 #3
0
 def test_items_post_order_with_3_strings(self):
     # Create a complete binary search tree of 3 strings in level-order
     items = ['B', 'A', 'C']
     tree = BinarySearchTree(items)
     # Ensure the post-order traversal of tree items is ordered correctly
     assert tree.items_post_order() == ['A', 'C', 'B']