Postorder Traversal

Learn more about postorder traversal and how to code it iteratively and recursively.

Iterative postorder tree traversal

Postorder traversal holds enormous value in the theoretical world of computer science and is better at deleting or removing the nodes of tree-like data structures. Like with a linked list, in preorder traversal, we start from the root or head node and then move until we reach the leaf node.

Postorder tree traversal represents just the opposite. Here the root node is visited last. We start from the left subtree, visit the right subtree, and then reach the root node.

Therefore, we should use recursion to visit the left subtree. Recursively visiting the right subtree leads us to our final destination: the root node. Postorder tree traversal follows this algorithm.

Get hands-on with 1200+ tech skills courses.