← DSADSA 3.1
Binary Trees
Not started yet — 18 problems queued, opening Trees once Binary Search and Recursion are solid.
DFS (pre/in/post-order, recursive or iterative with an explicit stack) explores depth-first; BFS (level-order, queue-based) explores breadth-first. Most tree problems reduce to "what do I compute at this node from my children's results" — think bottom-up (post-order) vs. top-down (passing state downward).
Sub-patterns
- A — DFS Traversals. Pre/in/post-order, recursive or with an explicit stack.
- B — BFS / Level-Order. Queue-driven, level by level.
- C — Path Problems. Root-to-leaf and any-to-any path sums and lengths.
- D — Tree Construction from Traversals. Rebuild a tree given two traversal orders.
- E — Symmetry & Comparison. Comparing a tree against itself or another tree.
- F — Lowest Common Ancestor. Find the deepest shared ancestor of two nodes.
Practice set (18)
- Easy — Maximum Depth of Binary Tree, Invert Binary Tree, Same Tree, Symmetric Tree, Path Sum, Diameter of Binary Tree, Balanced Binary Tree
- Medium — Binary Tree Level Order Traversal, Binary Tree Zigzag Level Order Traversal, Construct Binary Tree from Preorder and Inorder Traversal, Lowest Common Ancestor of a Binary Tree, Path Sum II, Binary Tree Right Side View, Flatten Binary Tree to Linked List, Populating Next Right Pointers in Each Node
- Hard — Binary Tree Maximum Path Sum, Serialize and Deserialize Binary Tree, Vertical Order Traversal of a Binary Tree
Pending
DFS Traversals
Pre/in/post-order traversal, recursive or with an explicit stack.
Pending
BFS / Level-Order
Queue-driven traversal, level by level.
Pending
Path Problems
Root-to-leaf and any-to-any path sum and path length problems.
Pending
Tree Construction from Traversals
Rebuild a tree given two of its traversal orders.
Pending
Symmetry & Comparison
Comparing a tree against a mirror of itself, or against another tree.
Pending
Lowest Common Ancestor
Find the deepest node that is an ancestor of two given nodes.
Notes from readers
Comments — via GitHub