Iterative Tree Traversals

medium
Checkpoint challenge
Solve this to show you know the material and jump straight to Unit 18. Everything before it counts as cleared.

Implement iterative (no recursion) traversals of a binary tree of TreeNode(val, left, right):

  • inorder(root): left, node, right
  • preorder(root): node, left, right
  • postorder(root): left, right, node

Each returns a list of values. A helper build(values) creating a tree from a level-order list (with None for gaps) is provided in the starter.

#trees#stacks#traversal2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Iterative Tree Traversals · TechGradify