Approximate Range Mode and Range Median Queries

  • Prosenjit Bose
  • Evangelos Kranakis
  • Pat Morin
  • Yihui Tang
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3404)


We consider data structures and algorithms for preprocessing a labelled list of length n so that, for any given indices i and j we can answer queries of the form: What is the mode or median label in the sequence of labels between indices i and j. Our results are on approximate versions of this problem. Using \(O(\frac{n}{1-\alpha})\) space, our data structure can find in \(O({\rm log}{\rm log}_\frac{1}{\alpha} n)\) time an element whose number of occurrences is at least α times that of the mode, for some user-specified parameter 0 < α< 1. Data structures are proposed to achieve constant query time for α=1/2,1/3 and 1/4, using storage space of O(n log n), O(n log log n) and O(n), respectively. Finally, if the elements are comparable, we construct an \(O(\frac{n}{1-\alpha})\) space data structure that answers approximate range median queries. Specifically, given indices i and j, in O(1) time, an element whose rank is at least \(\alpha \times \lfloor|j-i+1|/2\rfloor\) and at most \((2-\alpha)\times\lfloor|j-i+1|/2\rfloor\) is returned for 0 < α< 1.


Storage Space Lookup Table Query Range Query Time Approximation Factor 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Alon, N., Schieber, B.: Optimal preprocessing for answering on-line product queries. Technical Report 71/87, Tel-Aviv University (1987)Google Scholar
  2. 2.
    Arasu, A., Manku, G.S.: Approximate counts and quantiles over sliding windows. In: Proceedings of the ACM Symposium on Principles of Database Systems, PODS (2004)Google Scholar
  3. 3.
    Battiato, S., Cantone, D., Catalano, D., Cincotti, G., Hofri, M.: An efficient algorithm for the approximate median selection problem. In: Proceedings of the Fourth Italian Conference (2000)Google Scholar
  4. 4.
    Ben-Or, M.: Lower bounds for algebraic computation trees. In: Proceedings of the 15th annual ACM Symposium on the Theory of Computing, pp. 80–86 (1983)Google Scholar
  5. 5.
    Blum, M., Floyd, R.W., Pratt, V., Rivest, R.L., Tarjan, R.E.: Time bounds for selection. Journal of Computer and System Sciences 7(4), 448–461 (1973)zbMATHCrossRefMathSciNetGoogle Scholar
  6. 6.
    Datar, M., Gionis, A., Indyk, P., Motwani, R.: Maintaining stream statistics over sliding windows. SIAM Journal of Computing 31(6), 1794–1813 (2002)zbMATHCrossRefMathSciNetGoogle Scholar
  7. 7.
    Demaine, E.D., Lópex-Ortiz, A., Munro, J.I.: Frequency estimation of internet packet streams with limited space. In: Proceedings of the 10th Annual European Symposium on Algorithms, pp. 348–360 (2002)Google Scholar
  8. 8.
    Driscoll, J.R., Sarnak, N., Sleator, D.D., Tarjan, R.E.: Making data structures persistent. Journal of Computer and System Sciences 38(1), 86–124 (1989)zbMATHCrossRefMathSciNetGoogle Scholar
  9. 9.
    Gabow, H.N., Tarjan, R.E.: A linear-time algorithm for a special case of disjoint set union. Journal of Computer and System Sciences 30(2), 209–221 (1985)zbMATHCrossRefMathSciNetGoogle Scholar
  10. 10.
    Krizanc, D., Morin, P., Smid, M.: Range mode and range median queries on lists and trees. In: Ibaraki, T., Katoh, N., Ono, H. (eds.) ISAAC 2003. LNCS, vol. 2906, pp. 517–526. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  11. 11.
    Lin, X., Liu, H., Xu, J., Yu, J.X.: Continuously maintaining quantile summaries of the most recent n elements over a data stream. In: Proceedings of the 20th International Conference on Data Engineering (2004)Google Scholar
  12. 12.
    Manku, G.S., Rajagopalan, S., Lindsay, B.: Approximate median and other quantiles in one pass and with limited memory. In: Proceedings of the 1998 ACM SIGMOD International Conference on Management of Data, pp. 426–435 (1998)Google Scholar
  13. 13.
    Yao, A.C.: Space-time tradeoff for answering range queries. In: Proceedings of the 14th annual ACM Symposium on the Theory of Computing, pp. 128–136 (1982)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2005

Authors and Affiliations

  • Prosenjit Bose
    • 1
  • Evangelos Kranakis
    • 1
  • Pat Morin
    • 1
  • Yihui Tang
    • 1
  1. 1.School of Computer ScienceCarleton UniversityOttawa, OntarioCanada

Personalised recommendations