Iterative Tree Traversals

medium
Unit 17 · Greedy & Trees0/3 to milestone

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