Visualize Depth-First Search on a Binary Tree: pre-order, in-order, and post-order traversals, along with classic DFS patterns like Path Sum and LCA.
A Binary Tree is a hierarchical data structure where each node has at most two children. This visualizer lets you explore tree operations and traversals.
In a Binary Tree, each node has a value and pointers to its left and right children. This hierarchy allows for efficient searching and organization of data.
Visits nodes in order: Left subtree, then the Root node, then the Right subtree (Left -> Root -> Right).
Visits nodes in order: Root node first, then the Left subtree, then the Right subtree (Root -> Left -> Right).
Visits nodes in order: Left subtree, then the Right subtree, then finally the Root node (Left -> Right -> Root).
Also known as Breadth-First Search (BFS). Visits all nodes at the current depth before moving to the next level down.
Hover over any node with missing children to see "+" icons (Ghost Nodes). Click them to insert a new Left or Right child at that position.
Large trees can be hard to see. Click and drag the canvas to Pan. Use the mouse wheel or the UI controls to Zoom in and out.
Traversals are ways of visiting all nodes in the tree. Each method visits nodes in a unique order, which is useful for different computational tasks.