Data Structures & AlgorithmsHardGATE CS · ICPC regional
Distinct keys are inserted in this order into an empty binary search tree: 25 45 51 93 63 52 92 61 84. A search is run for the key 84 (which is present), starting at the root. How many nodes are examined, counting each node whose key is compared with the search key (a missing child is not a node)?
- A. 6
- B. 4
- C. 1
- D. 7
Correct answer: D. 7
The path is 25 → 45 → 51 → 93 → 63 → 92 → 84: 7 nodes compared. Counting edges gives 6, assuming a balanced tree gives ⌈log₂ 10⌉ = 4, and 1 would mean 84 is the root.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Distinct keys are inserted in this order into an empty binary search tree: 20 30 48 42 24 69 18 31 53 50. A search is run for the key 18…
- Distinct keys are inserted in this order into an empty binary search tree: 97 84 88 12 79 73 45 58 74 89 40. A search is run for the key…
- Distinct keys are inserted in this order into an empty binary search tree: 62 83 41 52 60 18 90 63 16 44 64. A search is run for the key…
- Distinct keys are inserted in this order into an empty binary search tree: 86 20 69 27 47 78 75 23 28 36. A search is run for the key 61…
- Distinct keys are inserted in this order into an empty binary search tree: 80 63 98 67 27 69 50 78 74 82 62. A search is run for the key…
- Distinct keys are inserted in this order into an empty binary search tree: 18 83 34 90 27 11 54 29 76 37 23. A search is run for the key…