Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 549 Bytes

File metadata and controls

25 lines (18 loc) · 549 Bytes
    int floor(Node* root, int x) {
      
        if(root==NULL)
            return -1;
            
        if(root->data ==x)
            return root->data;
            
        if(root->data < x)
        {
            
            int fright=floor(root->right,x);
            if(fright==-1)
                return root->data;
            
            return fright;
        }
    
        else
            return floor(root->left,x);
    }