AlgoScope

Postorder Traversal

Finish both subtrees before writing the node down, so the root comes last.

Tree algorithms, algorithm, beginner
Visiting 20, number 1 of 7. The order so far is 20.20304050607080current
Visiting 20, number 1 of 7. The order so far is 20.20304050607080current

Tree Traversals: Postorder, root comes last

Decision, step 2 of 9

20 is the deepest node on the far left, so it finishes first.

How tree traversals works

Cost

Best
O(n)
Average
O(n)
Worst
O(n)
Space
O(h)

Leads to

Topics that need this one first.

Taught by the same lesson

Tree Traversals covers these too, in the same run.