Incremental median computation with max memory efficiency

后端 未结 4 2007

I have a process that generates values and that I observe. When the process terminates, I want to compute the median of those values.

If I had to compute the mean, I

4条回答
  •  隐瞒了意图╮
    2020-12-10 01:55

    You can

    • Use statistics, if that's acceptable - for example, you could use sampling.
    • Use knowledge about your number stream
      • using a counting sort like approach: k distinct values means storing O(k) memory)
      • or toss out known outliers and keep a (high,low) counter.
      • If you know you have no duplicates, you could use a bitmap... but that's just a smaller constant for O(n).

提交回复
热议问题