Practice Overview

These problems take the ideas and techniques you learned in the chapter and apply them to new contexts. It is best to attempt these after reading the chapter and feeling confident with the material. For each problem, write your own solution before reading the provided one. Give yourself more time to work through the challenge.

You can download the accompanying code for these practice problems: starter and solution.

The three problems all ask the same thing: rewrite a recursive traversal without recursion. They get harder in order, so take them in the order listed.

  1. Why Write Iterative Traversals
  2. Problem: Iterative Pre-order Traversal
  3. Solution: Right Child First
  4. Problem: Iterative In-order Traversal
  5. Solution: Following the Left Spine
  6. Problem: Iterative Post-order Traversal
  7. Solution: Pre-order in Reverse