Recall & Review
beginner
What is inorder traversal in a binary tree?
Inorder traversal visits nodes in this order: left child, root node, then right child. It means we first go to the left subtree, then visit the root, and finally the 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 order. This helps to get sorted data from the tree easily.
Click to reveal answer
beginner
What is the order of visiting nodes in inorder traversal?
The order is: Left subtree → Root node → Right subtree.
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 as: 1 → 2 → 3
Click to reveal answer
beginner
What is the base case in recursive inorder traversal?
The base case is when the current node is null (no node). Then, we stop and return.
Click to reveal answer
In inorder traversal, which node do we visit first?
✗ Incorrect
In inorder traversal, we always visit the left child first.
What is the inorder traversal output of a BST with nodes 2 (root), 1 (left), 3 (right)?
✗ Incorrect
Inorder traversal visits left, root, right, so output is 1 → 2 → 3.
Which traversal gives nodes in ascending order for a BST?
✗ Incorrect
Inorder traversal visits BST nodes in ascending order.
What should the recursive function do when it reaches a null node in inorder traversal?
✗ Incorrect
When node is null, recursion returns immediately (base case).
In inorder traversal, after visiting the left subtree, what is visited next?
✗ Incorrect
After left subtree, we visit the root node.
Explain how inorder traversal works on a binary tree.
Think about the order of visiting nodes and how recursion helps.
You got /5 concepts.
Why is inorder traversal important for binary search trees?
Consider the BST property and how inorder visits nodes.
You got /4 concepts.