private BigSmall nextBigSmall(int[] tree,int index,int min,int max){
        BigSmall bs = new BigSmall();
        boolean seenBig = false, seenSmall = false;
        for(int i=index+1; i < tree.length && (!seenBig || !seenSmall); i++){
            if(tree[i] > max || tree[i] < min){
                continue;
            }
            if(!seenBig && tree[i] > tree[index]){
                bs.big = i;
                seenBig = true;
            }
            if(!seenSmall && tree[i] < tree[index]){
                bs.small = i;
                seenSmall = true;
            }
        }
        return bs;
    }
http://www.geeksforgeeks.org/check-for-identical-bsts-without-building-the-trees/
Test cases
Both array should be same size and have exact same elements and first element should be same
src/com/interview/tree/IdenticalTrees.java