In a binary tree, what is the in-order traversal of the tree with root 1, left c
Practice Questions
Q1
In a binary tree, what is the in-order traversal of the tree with root 1, left child 2, and right child 3?
1, 2, 3
2, 1, 3
3, 1, 2
1, 3, 2
Questions & Step-by-Step Solutions
In a binary tree, what is the in-order traversal of the tree with root 1, left child 2, and right child 3?
Step 1: Identify the structure of the binary tree. The tree has a root node with value 1, a left child with value 2, and a right child with value 3.
Step 2: Understand the in-order traversal method. In in-order traversal, we visit the left child first, then the root node, and finally the right child.
Step 3: Start the in-order traversal from the root node (1).
Step 4: Move to the left child of the root (2). Since 2 has no children, we visit 2 first.
Step 5: After visiting 2, we go back to the root node (1) and visit it next.
Step 6: After visiting the root (1), we move to the right child (3). Since 3 has no children, we visit 3 last.
Step 7: Combine the visited nodes in the order they were visited: 2 (left), 1 (root), 3 (right).