JIGYASA
Would you like to react to this message? Create an account in a few clicks or log in to continue.
JIGYASA

An online placement forum.


You are not connected. Please login or register

Closest Common ancestor

Go down  Message [Page 1 of 1]

1Closest Common ancestor Empty Closest Common ancestor Sun Sep 12, 2010 6:48 am

Lucifer


Admin

Given 2 nodes(say, pointer to the node is given) in a binary tree, find the closest common ancestor.

Code:

    Input:
                                1
              2                                  3
      4                5                  6              7
  8        9      10        11        12      13    14      15

Output:
Closest Common ancestor :
              (9,11) -> 2
              (9,14) -> 1

https://jigyasa.forumotion.com

Back to top  Message [Page 1 of 1]

Similar topics

-

» LCA (least common ancestor)

Permissions in this forum:
You cannot reply to topics in this forum