Recall & Review
beginner
What is the order of nodes visited in an inorder tree traversal?
Inorder traversal visits nodes in the order: Left subtree, then Root node, then Right subtree.
Click to reveal answer
beginner
Why is inorder traversal useful for binary search trees (BST)?
Inorder traversal of a BST visits nodes in ascending sorted order because it visits left (smaller), root, then right (larger).
Click to reveal answer
beginner
What is the base case in a recursive inorder traversal function?
The base case is when the current node is null (no node), then the function returns without doing anything.
Click to reveal answer
beginner
Given the tree: <br> 1<br> / \<br>2 3<br>What is the inorder traversal output?
The inorder traversal visits left (2), root (1), right (3). So the output is: 2 -> 1 -> 3
Click to reveal answer
beginner
Show the recursive steps for inorder traversal on a node.
1. Traverse left subtree recursively.<br>2. Visit the root node (process or print it).<br>3. Traverse right subtree recursively.
Click to reveal answer
In inorder traversal, which node is visited first?
✗ Incorrect
Inorder traversal always visits the left subtree first before the root.
What is the inorder traversal output of a BST with nodes 2, 1, 3?
✗ Incorrect
Inorder traversal of BST visits nodes in ascending order: 1, 2, 3.
What happens when the inorder traversal function reaches a null node?
✗ Incorrect
The base case for recursion is when the node is null, so the function returns immediately.
Which traversal order is correct for inorder?
✗ Incorrect
Inorder traversal visits left subtree first, then root, then right subtree.
In inorder traversal, when do we visit the root node?
✗ Incorrect
The root node is visited after the left subtree and before the right subtree.
Explain the steps of inorder traversal on a binary tree node.
Think about the order: left, root, right.
You got /4 concepts.
Why does inorder traversal produce sorted output for a binary search tree?
Consider how BST nodes are arranged.
You got /5 concepts.