Question d’entretien chez Microsoft

find common ancestor in binary tree

Réponses aux questions d'entretien

Utilisateur anonyme

13 mars 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.

Utilisateur anonyme

2 avr. 2011

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