Exam-style question
Try this first
A binary tree search starts at the root node with value 50. The left child is 30 and the right child is 70. The target value is 30. Which node is examined first, and what happens next?.
- A.30 is examined first, so the search moves right
- B.50 is examined first, then the search moves left
- C.70 is examined first, then the search moves left
- D.50 is examined first, then the search moves right
Model answer
What a good answer should say
- B.
- 50 is examined first, then the search moves left
Explanation
Why this works
A binary tree search begins at the root. Since 30 is less than 50, the search follows the left branch after examining 50.
Common mistake
No common mistake is linked to this question yet.
