Pregunta de entrevista de Microsoft

find common ancestor in binary tree

Respuestas de entrevistas

Anónimo

13 mar 2011

1. Start from the root node of the tree. 2. Check that the value of both the nodes to be compared should be either more than, or less than the root node. 2a. If its more than the root, then traverse to the right child node, and check the same condition. 2b. If its less than the root, then traverse to the left child node, and check the same condition. 3. Keep recursing until you find the node where this condition is falsified.

Anónimo

2 abr 2011

@MrB The question is about a Binary Tree, not a Binary Search Tree.