Recall & Review
beginner
What is the order of nodes visited in an inorder tree traversal?
In inorder traversal, nodes are visited in the order: Left subtree, then Root node, and finally 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) nodes.
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
Show the inorder traversal output for this tree:<br>Root=2, Left=1, Right=3
The inorder traversal visits nodes in order: 1 (left), 2 (root), 3 (right). So output is: 1 -> 2 -> 3
Click to reveal answer
beginner
What is the time complexity of inorder traversal on a binary tree with n nodes?
The time complexity is O(n) because each node is visited exactly once.
Click to reveal answer
In inorder traversal, which node is visited first?
✗ Incorrect
In inorder traversal, the left subtree is visited first before the root.
What is the output of inorder traversal on a BST with nodes 5, 3, 7?
✗ Incorrect
Inorder traversal visits left, root, right, so nodes are visited in ascending order.
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 always visits left subtree first, then root, then right subtree.
How many times is each node visited in inorder traversal?
✗ Incorrect
Each node is visited exactly once during inorder traversal.
Explain the steps of inorder traversal on a binary tree.
Think about visiting left first, then root, then right.
You got /4 concepts.
Describe why inorder traversal outputs sorted nodes in a binary search tree.
Connect BST ordering with traversal order.
You got /3 concepts.