The following function updates the countSmaller array to contain count of smaller elements on right side .
void constructLowerArray ( int arr [ ] , int countSmaller [ ] , int n ) { int i , j ; struct node * root = NULL ;