Iterative Tree Traversal
A fixed 9-node binary tree (the same tree from Sequence 12) is already built for you. Implement iterative_preorder(root) and iterative_inorder(root), both using an explicit stack, not recursion.
Read a choice ("pre" or "in") and print the corresponding traversal's values, space-separated.
main.py
Loading editor…
Console
Run your code to see output here.