Data Structures & AlgorithmsHardProduct-company placement · GATE CS
The keys [99, 12, 32, 75, 48, 66, 19, 63, 85, 55] are inserted, in this order, into an initially empty binary search tree (no rebalancing). How many nodes lie on the longest root-to-leaf path, counting both the root and the leaf?
- A. 7
- B. 8
- C. 4
- D. 1
Correct answer: B. 8
Insertion builds the chain 99 → 12 → 32 → 75 → 48 → 66 → 63 → 55: 8 nodes on the longest root-to-leaf path. Counting edges gives 7, a balanced tree would need only ⌈log₂ 11⌉ = 4 levels, and 1 counts the root alone.
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
- The keys [75, 40, 79, 13, 60, 24, 10, 88] are inserted, in this order, into an initially empty binary search tree (no rebalancing). How…
- The keys [29, 31, 12, 73, 89, 19, 39, 87] are inserted, in this order, into an initially empty binary search tree (no rebalancing). How…
- The keys [51, 64, 57, 69, 40, 23, 99] are inserted, in this order, into an initially empty binary search tree (no rebalancing). How many…
- The keys [50, 86, 83, 88, 23, 30, 91, 31, 68] are inserted, in this order, into an initially empty binary search tree (no rebalancing)…
- The keys [88, 87, 65, 73, 34, 44] are inserted, in this order, into an initially empty binary search tree. What is the preorder traversal…
- The keys [29, 53, 76, 4, 31, 57, 23, 22, 69, 99] are inserted, in this order, into an initially empty binary search tree. What is the…