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?

  1. A. 7
  2. B. 8
  3. C. 4
  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.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic