def test_can_successfully_return_a_collection_from_a_postorder_traversal(): new_tree = BinaryTree() new_tree.root = Node("A") new_tree.root.left = Node("B") new_tree.root.right = Node("C") new_tree.root.right.left = Node("F") new_tree.root.left.left = Node("D") new_tree.root.left.right = Node("E") expected = ["D", "E", "B", "F", "C", "A"] actual = new_tree.postOrder() assert expected == actual
def test_6 (): node1 = TNode(1) node1.left = TNode(2) node1.right = TNode(3) node1.right.left = TNode(5) node1.right.right = TNode(4) node1.left.right = TNode(6) node1.left.left = TNode(7) binary_tree = BinaryTree(node1) actual = binary_tree.postOrder().__str__() expected = '-> 1 -> 3 -> 4 -> 5 -> 2 -> 6 -> 7 -> None' assert actual == expected