Binary Search Tree : Lowest Common Ancestor

  • + 0 comments
        while(r != NULL){
            if(x < r->data && y < r->data)
                r = r->left;
            else if(x > r->data && y > r->data)
                r = r->right;
            else
                break;
        }
        return r;
    }