Range Medians
Abstract
We study a generalization of the classical median finding problem to batched query case: given an array of unsorted n items and k (not necessarily disjoint) intervals in the array, the goal is to determine the median in each of the intervals in the array. We give an algorithm that uses O(n n + k k n) comparisons and show a lower bound of (n k) comparisons for this problem. This is optimal for k=O(n/ n).
0