Fast algorithm for repeated calculation of percentile?

前端 未结 6 747
余生分开走
余生分开走 2020-12-12 17:21

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:

  1. Get value x
  2. Inse
6条回答
  •  -上瘾入骨i
    2020-12-12 18:00

    You can use binary search to do find the correct position in O(log n). However, shifting the array up is still O(n).

提交回复
热议问题