Data Structures & AlgorithmsVery hardProduct-company placement · GATE CS

The keys [55, 6, 10, 36, 89, 11, 26, 80, 54, 86, 33] 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. 8
  2. B. 6
  3. C. 7
  4. D. 11

Correct answer: C. 7

Insertion walks left for smaller keys and right otherwise. The longest path counted in nodes is one more than its length in edges; reporting the edge count, or the total number of nodes, is the usual slip.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic