Now we try to implement the 2nd additional operation of an order-statistic tree i.e. find the kth smallest element.
Algo :
kth smallest element lies in range [1,N].
if number of elements smaller than or equal to some x is >= k then kth smallest element lies in range [1,x]
else kth smallest element lies in range [x + 1, N].
Using these observations we apply binary search and to find number of elements less than some number x we use sum(1, x) operation of the BIT.
what is the time complexity?