Binary Search Tree : Lowest Common Ancestor

  • + 0 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.