Skip to main content

Iterative Traversal

Learn Iterative Traversal (Trees, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Iterative Preorder - an Explicit Stack Replaces the Call Stack Any recursive traversal can be rewritten iteratively using an explicit Stack / Deque that manually does what the call stack did implicitly. For preorder, push right BEFORE left, so left gets popped (and processed) FIRST.

More lessons in Trees