Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
332 B
1
Indexable
Never
int findCeil(BinaryTreeNode<int> *root, int X){
    if (root == NULL)
        return -1;

    if (root -> data == X)
        return root -> data;
    else if (X > root -> data)
        return findCeil(root -> right, X);
    else {
        int val;
        return (val = findCeil(root -> left, X)) != -1 ? val : root -> data;
    }
}