@@ -0,0 +1,2082 @@
+import java.util.*;%0A%0Aclass Tree %7B%0A    // List of node data values:%0A    Vector%3CInteger%3E values;%0A    // Total number of nodes in the tree:%0A    private int count;%0A%0A    Tree() %7B%0A        this.values = new Vector%3CInteger%3E();%0A        this.count = 0;%0A    %7D%0A%0A    static class Node %7B%0A        int data;%0A        Node left;%0A        Node right;%0A%0A        Node() %7B%0A            this.data = -1;%0A            this.left = null;%0A            this.right = null;%0A        %7D%0A    %7D%0A%0A    private boolean checkBST(Node n, int min, int max) %7B%0A        if(n == null) return true;%0A        return n.data %3E min && n.data %3C max && checkBST(n.left, min, n.data) && checkBST(n.right, n.data, max);%0A    %7D%0A%0A    boolean checkBST(Node root) %7B%0A        if(root == null) return true;%0A        if(count == 0) return true;%0A        return checkBST(root, Integer.MIN_VALUE, Integer.MAX_VALUE);%0A    %7D%0A%0A    void inOrder (Node root, int levels) %7B%0A%0A        if(root != null) %7B%0A            // If there are still unfilled levels, fill left subtree:%0A            if (levels %3E 0) %7B%0A                // Create a new left child node:%0A                root.left = new Node();%0A                inOrder(root.left, levels - 1);%0A            %7D%0A%0A            // Set node data:%0A            root.data = values.elementAt(count);%0A            count++;%0A%0A            // If there are still unfilled levels, fill right subtree:%0A            if (levels %3E 0) %7B%0A                // Create a new right child node:%0A                root.right = new Node();%0A                inOrder(root.right, levels - 1);%0A            %7D%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Scanner scanner = new Scanner (System.in);%0A%0A        int height = scanner.nextInt();%0A%0A        // Read data values for tree's nodes:%0A        Tree tree = new Tree();%0A        while(scanner.hasNext()) %7B%0A            tree.values.add(scanner.nextInt());%0A        %7D%0A        scanner.close();%0A%0A        // Fill tree:%0A        Node root = new Node();%0A        tree.inOrder(root, height);%0A%0A        // Print result:%0A        System.out.println( (tree.checkBST(root) == true) ? %22Yes%22 : %22No%22 );%0A%0A    %7D%0A%7D%0A

is-binary-search-tree