finding lowest common ancestor in binary search tree

Discussion in 'C' started by cuterocker, Jan 28, 2008.

  1. cuterocker

    cuterocker New Member

    Joined:
    Jan 28, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    1. Write a program to print Lowest Common Ancestor of given the values of two nodes in a binary search tree. You may assume that both values already exist in the tree.

    The program should take the inputs for the binary tree and construct the tree. Once the construction is over, the program takes 2 inputs to find out the LCA of those nodes.

    Eg: In the below given tree, the lowest common ancestor of 4 and 14 is 8.
     
  2. 7900142

    7900142 New Member

    Joined:
    Jan 12, 2011
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Free lance software developer, an instructor and a
    Location:
    Philippines
    cuterocker,
    Before I will give my code to you, let me verify the following:
    1. Will the program create an balance Binary Tree during/after the input?
    2. Is AVL a part of your program requirements?

    Just shoot an email, I will give you my solution to your problem.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice