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]

Interactive example available with JavaScript enabled.

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: