We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Postorder Traversal

A "postorder" traversal also visits all the nodes in a tree. It's called "postorder" because the current node is visited after its children. The following tree:

Would be visited in this order:

[2, 3, 7, 9, 12, 10, 8, 5]

Postorder Traversal

Watch a recursive traversal visit each node and build the output list.
5328710912
Visited
Current step
Start at the root, but wait to append until children are done.
Postorder is left subtree, right subtree, current.
1 / 18

Assignment

Our data team didn't like the way we ordered the users in our BST export (personally I think they just want to kick the work for themselves down the road). Anyhow, we've been asked to change it.

Implement the recursive postorder method. Here are the algorithm's steps: