Pattern18 visualizers
Binary Tree Pattern Visualizers
The Binary Tree pattern is a recurring algorithmic shape that appears across coding interviews and competitive problems. Use it when the problem geometry matches its trigger conditions — recognizing the pattern collapses what looks like a hard problem into a familiar template. These visualizers trace Binary Tree step-by-step on classics such as Balanced Binary Tree, Binary Tree Inorder Traversal, Binary Tree Level Order Traversal, so you can internalize the moves before you ever need them under pressure.
Binary Tree
Balanced Binary Tree
Bottom-up DFS checking if subtree heights differ by at most 1. Early termination on imbalance.
Open visualizer →
Binary Tree
Binary Tree Inorder Traversal
Recursive DFS visiting left, then root, then right. See how in-order produces sorted output for BSTs.
Open visualizer →
Binary Tree
Binary Tree Level Order Traversal
BFS level-order traversal using a queue. Watch nodes get visited level by level with queue state tracked in real time.
Open visualizer →
Binary Tree
Binary Tree Maximum Path Sum
Postorder DFS computing max gain from each subtree while tracking the global maximum path sum.
Open visualizer →
Binary Tree
Binary Tree Postorder Traversal
Recursive DFS visiting left, then right, then root. Children are always processed before their parent.
Open visualizer →
Binary Tree
Binary Tree Preorder Traversal
Recursive DFS visiting root, then left, then right. Watch the call stack and result array build in real time.
Open visualizer →
Binary Tree
Binary Tree Right Side View
BFS collecting the last node of each level. See which nodes are visible from the right side of the tree.
Open visualizer →
Binary Tree
Binary Tree Zigzag Level Order Traversal
BFS with alternating direction per level. Watch the zigzag pattern build as levels alternate left-to-right and right-to-left.
Open visualizer →
Binary Tree
Count Good Nodes in Binary Tree
DFS tracking the max value on the path from root. A node is good if its value >= max so far.
Open visualizer →
Binary Tree
Diameter of Binary Tree
DFS computing height while tracking max left+right height across all nodes to find the longest path.
Open visualizer →
Binary Tree
Invert Binary Tree
Recursive DFS swapping left and right children at every node. Watch the tree mirror itself.
Open visualizer →
Binary Tree
Lowest Common Ancestor of a Binary Tree
DFS returning p or q when found, identifying the LCA where both subtrees return non-null.
Open visualizer →
Binary Tree
Maximum Depth of Binary Tree
DFS recursion computing 1 + max(left, right) depth. Watch depth values propagate back up the tree.
Open visualizer →
Binary Tree
Path Sum
DFS exploring root-to-leaf paths with a running sum. Backtrack when a path doesn't reach the target.
Open visualizer →
Binary Tree
Populating Next Right Pointers in Each Node
BFS level-by-level connecting each node's next pointer to the next node in the same level.
Open visualizer →
Binary Tree
Same Tree
Recursive DFS comparing two trees node by node. Both structure and values must match.
Open visualizer →
Binary Tree
Subtree of Another Tree
For each node in the main tree, check if the subtree rooted there matches the target tree.
Open visualizer →
Binary Tree
Symmetric Tree
Recursive mirror check comparing left.left with right.right and left.right with right.left.
Open visualizer →