On binary searching with non-uniform costs

  • Authors:
  • Eduardo S. Laber;Ruy L. Milidiú;Artur A. Pessoa

  • Affiliations:
  • PESC/COPPE, Universidade Federal do Rio de Janeiro, Brazil;Departamento de Informática, PUC-Rio, Brazil;Departamento de Informática, PUC-Rio, Brazil

  • Venue:
  • SODA '01 Proceedings of the twelfth annual ACM-SIAM symposium on Discrete algorithms
  • Year:
  • 2001

Quantified Score

Hi-index 0.00

Visualization

Abstract

Let us consider an ordered vector A[1 : n]. If the cost of testing each position is similar, then the standard binary search is the best strategy to search the vector. This is true in both average and worst case. However, if the costs are non-uniform, then the best strategy is not necessarily the standard binary search. The best algorithm to construct a strategy that minimizes the expected search cost runs in &Ogr;(n3) time and requires &Ogr;(n2) space. The same complexities hold for the best algorithm to construct a strategy that minimizes the worst case search cost.Here, we show how to efficiently construct search strategies that are at most at a constant factor from the optimal one. These constructions take linear time and use only linear space. For the problem of minimizing the expected search cost, we present an algorithm that requires &Ogr;(n) space and gives a (2 + ∈ + &Ogr;(1))-approximated solution in &Ogr;(n) time, for any fixed value of ∈ 0. On the other hand, for the problem of minimizing the worst case search cost, we describe an algorithm that requires &Ogr;(n) space and gives a (2 + ∈ + &Ogr;(1))- approximated solution in &Ogr;(n) time, for any fixed value of ∈ 0. These two problems arise when processing a query in a distributed text database indexed by a suffix array.