public boolean isBSTIterative(Node root) {
        if (root == null) {
            return true;
        }

        Deque<Node> stack = new LinkedList<>();
        Node node = root;
        int prev = Integer.MIN_VALUE;
        int current;
        while ( true ) {
            if (node != null) {
                stack.addFirst(node);
                node = node.left;
            } else {
                if (stack.isEmpty()) {
                    break;
                }
                node = stack.pollFirst();
                current = node.data;
                if (current < prev) {
                    return false;
                }
                prev = current;
                node = node.right;
            }
        }
        return true;
    }
Date 04/11/2015
@author tusroy

Youtube link - https://youtu.be/MILxfAbIhrE

Given a binary tree, return true if it is binary search tree else return false.

Solution
Keep min, max for every recursion. Initial min and max is very small and very larger
number. Check if root.data is in this range. When you go left pass min and root.data and 
for right pass root.data and max.

Time complexity is O(n) since we are looking at all nodes.

Test cases:
Null tree
1 or 2 nodes tree
Binary tree which is actually BST
Binary tree which is not a BST
src/com/interview/tree/IsBST.java