top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Given root of a Binary Tree along with two integer values. Find the LCA of two nodes with values of the given integers..

0 votes
400 views

Given the root of a Binary Tree along with two integer values. Assume that both integers are present in the tree.
Find the LCA (Least Common Ancestor) of the two nodes with values of the given integers.
2 pass solution is easy. You must solve this in a single pass.

posted Nov 3, 2016 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+7 votes

A binary tree is given and two nodes of this tree is given, we have to find out the algorithm/code for lowest common ancestor of the two given nodes. Common ancestor are the nodes which can be reached from two nodes by following the parent links. Lowest common ancestor is the common ancestor which has the highest depth.

...