Exam-style question
Try this first
The values in the following binary search tree are arranged so that an in-order traversal should produce them in ascending order. Which sequence is produced by an in-order traversal of this tree: root 50, left child 30, right child 70, 30's children 20 and 40, and 70's children 60 and 80?.
- A.50, 30, 20, 40, 70, 60, 80
- B.20, 30, 40, 50, 60, 70, 80
- C.20, 40, 30, 60, 80, 70, 50
- D.80, 70, 60, 50, 40, 30, 20
Answer and explanation
Concise answer
20, 30, 40, 50, 60, 70, 80
Why this is correct
In-order visits the left subtree, then the current node, then the right subtree. For a binary search tree, this outputs the contents in ascending order.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
