# Can any one solve this Problem

Praveen Reddy

Ranch Hand

Posts: 51

posted 8 years ago

Hi All,

Can any one please help me by solving this problem.

Implement public Node GetLeastCommonAncenstor (Node m, Node n) such that it returns the node which has both m and n as a child. In the figure on the following page, passing the method nodes a and b will return node c because it is the first (least) node which contains both a and b. Please feel free to make any changes to the classes you feel are necessary; please document the changes and your reasons for making them. Note: the tree is a binary search tree, meaning that the nodes are sorted, with all the nodes on the left of each node being smaller than the nodes on the right.

public class Tree

{

public int GetNodeCount(Node n)

{

// return number of nodes

}

public Node GetLeastCommonAncenstor (Node m, Node n)

{

// return the least common ancenstor

}

}

public class Node

{

Node m_Left;

Node m_Right;

String m_Word;

}

Please check the below Sendspace link for Sample Binary Tree:

Thanks in Advance

Praveen

Can any one please help me by solving this problem.

Implement public Node GetLeastCommonAncenstor (Node m, Node n) such that it returns the node which has both m and n as a child. In the figure on the following page, passing the method nodes a and b will return node c because it is the first (least) node which contains both a and b. Please feel free to make any changes to the classes you feel are necessary; please document the changes and your reasons for making them. Note: the tree is a binary search tree, meaning that the nodes are sorted, with all the nodes on the left of each node being smaller than the nodes on the right.

public class Tree

{

public int GetNodeCount(Node n)

{

// return number of nodes

}

public Node GetLeastCommonAncenstor (Node m, Node n)

{

// return the least common ancenstor

}

}

public class Node

{

Node m_Left;

Node m_Right;

String m_Word;

}

Please check the below Sendspace link for Sample Binary Tree:

Thanks in Advance

Praveen

Praveen Reddy

Ranch Hand

Posts: 51