← Home onlinecstutor.com
Recursion — Tree Traversal

A-LEVEL · TREE TRAVERSAL

Tree traversal <stack meets heap>

Same tree, same recursive walk — switch between pre-order, in-order and post-order to watch how the call stack changes.

Heap — tree structure

Stack — call frames (bottom to top, left to right)

Visited so far — in-order output

Step of

not yet reached on call stack, waiting visited