private Node rightRotate(Node root){
        Node newRoot = root.left;
        root.left = root.left.right;
        newRoot.right = root;
        root.height = setHeight(root);
        root.size = setSize(root);
        newRoot.height = setHeight(newRoot);
        newRoot.size = setSize(newRoot);
        return newRoot;
    }
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