Find the position of the kth element in the interval in which it lies
$ x = $ k - $ total [ $ index - 1 ] ; while ( $ l <= $ h ) { $ m = floor ( ( $ l + $ h ) / 2 ) ; if ( ( $ m - $ L [ $ index - 1 ] ) + 1 == $ x ) { return $ m ; } else if ( ( $ m - $ L [ $ index - 1 ] ) + 1 > $ x ) $ h = $ m - 1 ; else $ l = $ m + 1 ; } }