# Postorder traversal

Last edited: 2026-02-13

Postorder traversal

Given a rooted tree where for every vertex we have a given ordering on the children. The postorder traversal visits nodes by: (1) recursively visiting all children in their given order from left to right, then (2) processing the current node.

The “post” in postorder means the parent node is processed after its descendants.

A simple example

Consider the following tree: Simple tree Suppose we traverse nodes left to right. Then the postorder traversal is: 1, 4, 3, 6, 5, 0, 7, 2.

Relation to depth first search

Postorder traversal is one way to implement a depth first search on a tree. DFS is a general traversal strategy that explores as far as possible along each branch before backtracking. Postorder specifically processes nodes after visiting their descendants.