In an algorithm I have to calculate the 75th percentile of a data set whenever I add a value. Right now I am doing this:
x
You can use binary search to do find the correct position in O(log n). However, shifting the array up is still O(n).