Your question is Tree Traversal in Python. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
HashedIn by Deloitte QA automation workflows may need deterministic traversal results when validating hierarchical test configurations. Given a binary tree, return its pre-order, in-order, and post-order traversals without recursively walking the tree.
Implement tree_traversals(root). The input root is either None or a nested dictionary with this structure: {"value": integer, "left": node_or_None, "right": node_or_None}. Return a dictionary with three keys: "preorder", "inorder", and "postorder", each containing a list of node values.
Use an iterative algorithm based on an explicit stack. The solution must preserve traversal ordering and should support highly unbalanced trees that may exceed Python's recursion limit.
def tree_traversals(root):