Data Structures & AlgorithmsHardGATE CS · ICPC regional
Distinct keys are inserted in this order into an empty binary search tree: 14 21 50 88 73 49 75 39 86 38. A search is run for the key 49 (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. 5
- B. 3
- C. 4
- D. 7
Correct answer: C. 4
Follow the search path from the root, one node per comparison: it examines 4 nodes. Counting the missing child as a node, or counting edges instead of nodes, shifts the answer by one.
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: 25 45 51 93 63 52 92 61 84. A search is run for the key 84…
- 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…