Data Structures & AlgorithmsHardTCS NQT · Trees

Keys 50, 30, 70, 20, 40, 60, 80, 35, 45, 65, 85 are inserted into an empty BST in this order. What is the lowest common ancestor of the nodes 35 and 45?

  1. A. 30
  2. B. 35
  3. C. 40
  4. D. 50

Correct answer: C. 40

Both 35 (left child) and 45 (right child) hang below 40, which is the lowest node having them in different subtrees.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic