public int[] count(int input[]){
        int count[] = new int[input.length];
        Node root = null;
        for(int i=input.length-1; i >= 0; i--){
            root = insert(root,input[i],count,i,0);
        }
        return count;
    }
http://www.geeksforgeeks.org/count-smaller-elements-on-right-side/
Test cases
All same elements
Many duplicates
Negative numbers
0s
Sorted or reverse sorted
src/com/interview/tree/CountNumberOfSmallerElementOnRight.java