Tree Traversal
Domain: Data Structures
🎯 Motivation
To process every node in a tree, you need a systematic way to visit them all. Different traversal orders serve different purposes.
📋 Concrete Example
Three common orders for tree [A(B,C)]: Pre-order (A,B,C), In-order (B,A,C), Post-order (B,C,A). In-order on a BST gives sorted output.
🔗 Analogy
Three ways to explore a shopping mall: visit each shop as you arrive (pre-order), visit left wing then the shop then right wing (in-order), or visit all shops in a wing before the anchor shop (post-order).