My Blog List

[Leetcode Solution] Binary Tree Postorder

Analysis

  • recursive solution is trivial, iterative one is required
  • Use a stake to store the traversal path. Add auxiliary variable for each node in stack to denote the searching state. Then when the search procedure backtracking to a node visited before, the auxiliary variable will show how to traversal this node now.

Note

  • Recursive and non-recursive way to traversal a binary tree in postorder

Code