Suppose that we have numbers between 1 and 1,000 in a binary search tree and want to search for the number 364. Which of the following sequences could not…
Suppose that we have numbers between 1 and 1,000 in a binary search tree and want to search for the number 364. Which of the following sequences could not be the sequence of nodes examined?
Show answerHide answer
Correct answer: (C) 926, 203, 912, 241, 913, 246, 364
Explanation
In sequence (c), after visiting 912 (912 > 364) the search moves to the left subtree of 912, so every later node must be less than 912. 913 cannot appear after 912. So, the answer is (c).