For the following definition of a binary tree node typedef struct _Node { _Node * Left; _Node * Rigth; _Node * Parent; } Node;
Given 2 nodes u and v from a tree, find the closest common ancestor of u and v? Node* ClosestCommonAncestor(Node* u, Node* v) here is what i think. Node* ClosestCommonAncestor(Node* u, Node* v) { if( u == v) return u->parent; while( u != v | u != root | v!= root){ u = u->parent; v = v->parent; } return u; } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---