You are viewing a single comment's thread. Return to all comments →
node * lca(node * root, int v1,int v2) { if(root==NULL) { return NULL; }
if(v1>root->data && v2>root->data) { lca(root->right,v1,v2); }
else if(v1data && v2data) { lca(root->left,v1,v2); }
return root; } same here test case 2 is where my code fails but in case of try and run it's working pretty well.
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 →
node * lca(node * root, int v1,int v2) { if(root==NULL) { return NULL; }
else if(v1data && v2data) { lca(root->left,v1,v2); }
return root; } same here test case 2 is where my code fails but in case of try and run it's working pretty well.