You are viewing a single comment's thread. Return to all comments →
C#:
public Node LowestCommonAncestor(Node n1, Node n2) { if (n1.FindNode(n2.Data) != null) return n1; if (n2.FindNode(n1.Data) != null) return n2; if(n1.Parent == n2.Parent) return n1.Parent; return LowestCommonAncestor(n1.Parent, n2.Parent); }
Seems like cookies are disabled on this browser, please enable them to open this website
Binary Search Tree : Lowest Common Ancestor
You are viewing a single comment's thread. Return to all comments →
C#: