Binary Trees & Traversals
Represent binary trees and solve tree problems with depth-first and level-order traversals.
3 objectives 6 steps about 120 min
Check what you know
The lessons are coming later. The knowledge check is ready now.
This skill page is a public outline. Its lessons and knowledge check appear here as subject-matter experts approve them.
Learning objectives
- Implement preorder, inorder and postorder traversals both recursively and iteratively, and level-order traversal with a queue.
- Solve tree problems by combining values returned from subtrees (height, diameter, balance check, path sums, lowest common ancestor) in O(n).
- Serialize and deserialize a binary tree and rebuild one from its preorder and inorder sequences.
Lesson plan
6 steps, about 120 min · 0 of 5 lessons available so far
- Tree Vocabulary and Node Representation Concept · 15 min · coming later
- Three Depth-First Orders, Two Ways Worked example · 25 min · coming later
- Level by Level with a Queue Worked example · 15 min · coming later
- Answers That Bubble Up from Subtrees Worked example · 25 min · coming later
- Lab: Serialize, Deserialize, Rebuild Lab · 25 min · coming later
- Check: Tree Traversal Problems Knowledge check · 6 questions
Practise it
Write functions for maximum depth, diameter, right-side view, path-sum count and lowest common ancestor, plus a serialize/deserialize pair whose round trip is verified on 500 randomly generated trees.
Build it from scratch
Practice builds that exercise this skill by re-creating a real technology.
- Build your own Programming LanguageIntermediate · 20–40 h
- Build your own CompilerAdvanced · 30–60 h
References
Hard prerequisites
Unlocks
On these roadmaps
Progress and evidence for this skill are shared across all of them.