Forums Register Login

Can any one solve this Problem

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
+Pie Number of slices to send: Send
What is your solution, and what problems are you having with it?
Those are the largest trousers in the world! Especially when next to this ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 989 times.
Similar Threads
BST problem (Online waiting)
XPath expression constrained by a predicate doesn't work (//element[@attribute="value"])
need help figurng out what is wrong with my A* search algorithm for an eight puzzle
evaluate the expression
Tree creation problem
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:30:45.