youtube_tutorials
youtube_tutorials copied to clipboard
Wrong output
print(tree.print_tree("postorder"))
4-5-2-6-7-3-1-
not:
4-2-5-6-3-7-1
Can you please refer to the offending file for which your comment is directed to?
Yes of course. Btw thanks for your work! data_structures/trees/binary_trees/binary_tree_recursive_dfs_traversals.py def postorder_print(self, start, traversal): """Left->Right->Root""" if start: traversal = self.postorder_print(start.left, traversal) traversal = self.postorder_print(start.right, traversal) traversal += (str(start.value) + "-") return traversal
1-2-4-5-3-6-7-
4-2-5-1-6-3-7
# 4-2-5-6-3-7-1
1
/ \
2 3
/ \ / \
4 5 6 7
I'm not sure I see the issue. The post-order recursively goes to the left, right, and then prints. This is the correct process for post-order traversal.