@@ -0,0 +1,2278 @@
+/* Hidden stub code will pass a root argument to the function below. Complete the function to solve the challenge. Hint: you may want to write one or more helper functions.%0A%0AThe Node class is defined as follows:*/%0A%0A/**%0A * Hackerrank: Trees: Is This a Binary Search Tree?%0A *%0A * @see %3Ca href=%22https://www.hackerrank.com/challenges/ctci-is-binary-search-tree%22%3ETrees: Is This a Binary Search Tree?%3C/a%3E%0A */%0Aclass Node %7B%0A    int data;%0A    Node left;%0A    Node right;%0A%0A%0A    /**%0A     * Check whether the current binary tree is a binary search tree%0A     *%0A     * @param root Root node of the binary tree%0A     * @return true if it is a binary search tree and false otherwise%0A     */%0A    boolean checkBST(Node root) %7B%0A        if (root == null) %7B%0A            return true;%0A        %7D%0A        if ((root.left != null) && (root.left.data %3E= root.data)) %7B%0A            return false;%0A        %7D%0A        if ((root.right != null) && (root.right.data %3C= root.data)) %7B%0A            return false;%0A        %7D%0A        return checkBST(root.right) && checkBST(root.left) && checkLeft(root.data, root.left) && checkRight(root.data, root.right);%0A    %7D%0A%0A    /**%0A     * Checking the left subtree if there are no values greater than the root value max%0A     *%0A     * @param max  value of the root of the current subtree%0A     * @param node current node%0A     * @return true if the values in the subtree are smaller than the max value and false otherwise%0A     */%0A    boolean checkLeft(int max, Node node) %7B%0A        if (node == null) %7B%0A            return true;%0A        %7D%0A        if (node.data %3C max) %7B%0A            return checkLeft(max, node.left) && checkLeft(max, node.right);%0A        %7D else %7B%0A            return false;%0A        %7D%0A    %7D%0A%0A    /**%0A     * Checking the right subtree if there are no values smaller than the root value min%0A     *%0A     * @param min  value of the root of the current subtree%0A     * @param node current node%0A     * @return true if the values in the subtree are greater than the min value and false otherwise%0A     */%0A    boolean checkRight(int min, Node node) %7B%0A        if (node == null) %7B%0A            return true;%0A        %7D%0A        if (node.data %3E min) %7B%0A            return checkRight(min, node.left) && checkRight(min, node.right);%0A        %7D else %7B%0A            return false;%0A        %7D%0A    %7D%0A%0A%0A%7D

Check binary tree whether it is a binary search tree