Towards Optimal Range Medians

  • Authors:
  • Beat Gfeller;Peter Sanders

  • Affiliations:
  • ETH Zürich, Switzerland;Universität Karlsruhe, Germany

  • Venue:
  • ICALP '09 Proceedings of the 36th International Colloquium on Automata, Languages and Programming: Part I
  • Year:
  • 2009

Quantified Score

Hi-index 0.00

Visualization

Abstract

We consider the following problem: given an unsorted array of n elements, and a sequence of intervals in the array, compute the median in each of the subarrays defined by the intervals. We describe a simple algorithm which uses O (n ) space and needs O (n logk + k logn ) time to answer k such median queries. This improves previous algorithms by a logarithmic factor and matches a lower bound for k = O (n ). Since, in contrast to previous approaches, the algorithm decomposes the range of element values rather than the array, it has natural generalizations to higher-dimensional problems --- it reduces a range median query to a logarithmic number of range counting queries.