[INST] Given a binary tree, check if it is a binary search tree. Write a Java function to do it. Assume the Node class is implemented./n [/INST]  ###Response: To check if a binary tree is a binary search tree (BST), we need to ensure that all the nodes in the left subtree of a node are less than or equal to the current node's value while all the nodes in the right subtree of a node are greater than the current node's value. Below is a Java function that checks if a binary tree is a BST.

```
public boolean isBST(Node root) {
    return isBST(root, Integer.MIN_VALUE, Integer.MAX_VALUE);
}

private boolean isBST(Node node, int min, int max) {
    if (node == null) {
        return true;
    }
    if (node.data < min || node.data > max) {
        return false;
    }
    return isBST(node.left, min, node.data - 1) && isBST(node.right, node.data + 1, max);
}
```

The `isBST` function takes in the root node of the binary tree and calls the private `isBST` function with the minimum and maximum possible integer values as the initial parameters. The `isBST` function checks if the node is null, in which case it returns true. Otherwise, it checks if the node's value is within the given range of min and max. If not, it returns false because the node violates the BST property. If the value is within the given range, it recursively checks the left and right subtrees with updated min and max values. If both subtrees return true, the function returns true.