Binary Trees: Recursive Traversals, BFS & Tree Diameter
Master hierarchical tree structures: TreeNode anatomy, Pre/In/Post-order traversals (recursive & iterative with explicit stack), BFS Level-Order, and tree diameter.
Recursion and pointer-based node hierarchies
Command of recursive and iterative tree traversals, Lowest Common Ancestor, tree diameter, and preorder serialization codecs.
Read in order, or jump to what you need.
Every lesson builds on the one before it. Open any lesson to read the explanation, run the examples, and try the practice challenges.
- 12.01Binary Tree Traversals: Pre, In & Post-Order (Recursive & Iterative)4 min
Deconstruct tree traversal algorithms. Contrast Depth-First Search (DFS) orderings, trace recursive call stacks, and implement iterative traversals using an explicit stack.
- 12.02Breadth-First Search: Level-Order Traversal & Tree Diameter4 min
Master horizontal tree traversals. Learn Breadth-First Search (BFS) using a Queue, level-by-level batching, zig-zag traversals, and calculating tree diameter.
- 12.03Tree Topology: Lowest Common Ancestor (LCA) and Tree Diameter Algorithms4 min
Solve structural tree problems through post-order recursion invariants: computing Lowest Common Ancestor (LCA) and the diameter (longest path) of a binary tree.
- 12.04Tree Codecs: Preorder Serialization and Level-Order Deserialization4 min
Design robust, compact tree serialization codecs to persist binary trees to string formats and reconstruct identical tree topologies via recursion and queues.
Ready to move on?
Serialize and deserialize complex binary trees with null sentinels.
Open the module self-check