AlgoScope

Reverse Level Order

Level order pushed onto a stack, right child first, then popped: bottom level first, left to right.

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: Reverse level order

Decision, step 2 of 9

20 is the leftmost node of the deepest level, the first popped off the stack.

How tree traversals works

Cost

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

A variant of

Taught by the same lesson

Tree Traversals covers these too, in the same run.