TreesAnimated
Postorder Traversal
Left, right, node. Visits children before parents.
Time
O(n)
Extra space
O(h)
Use it for
Deleting a tree; evaluating expression trees.
How it works
- Traverse the left subtree.
- Traverse the right subtree.
- Visit the node last.
- Children always come before their parent, which is what you need to delete a tree or evaluate an expression tree.
Watch it run
Loading animation…