struct node{
int data;
struct node* left;
struct node* right;
};
struct node* lca(struct node* root,struct node* a,struct node* b){
if(!root) return NULL;
if( root==a || root ==b) return root;
struct node* left = lca(root->left,a,b);
struct node* right = lca(root->right,a,b);
if( left && right) return root;
return (left ? left : right);
}
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.