Reverse Level Order
Level order pushed onto a stack, right child first, then popped: bottom level first, left to right.
Decision · step 2 of 9Tree Traversals: Reverse level order
20 is the leftmost node of the deepest level, the first popped off the stack.
What you will see
Levels light up top-down but are output bottom-up.
Cost
| Best | O(n) |
|---|---|
| Average | O(n) |
| Worst | O(n) |
| Space | O(n) |
How you work with it here
play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next, try operations in any order.
Screen readers: Nodes announce value, left child and right child; each step announces the comparison and the direction taken or the structural change.
Reduced motion: Focus jumps node to node with a static ring; rotations become a crossfade between the two layouts.
Before this
A variant of
Taught by the same lesson
Tree Traversals covers these too, in the same run.