LESSON 02 OF 08Tree DFS · inorder
0%
BINARY TREE INORDER TRAVERSAL · DEPTH-FIRST SEARCH
Visit every node in left → node → right order.
Click the next node DFS visits. The moving cursor shows recursion descending and returning through the tree.
INORDER RULELEFT SUBTREE → NODE → RIGHT SUBTREE
INPUT · BINARY SEARCH TREEA node stores a value. Each line connects a parent to its left or right child.
DFS cursor added to outputClick the node visited next
COMPUTER SCIENCE PROBLEM · BINARY TREES
Return a binary tree’s values in inorder.
A binary tree is made of nodes. Each node stores a value and can point to a left child and a right child. A traversal is the order in which an algorithm visits those nodes.
INPUT TREE
[4, 2, 6, 1, 3, 5, 7]EXPECTED OUTPUT[1, 2, 3, 4, 5, 6, 7]WHAT YOU WILL LEARNHow depth-first search, recursion, and the call stack produce an inorder traversal.