English

New Results for Adaptive and Approximate Counting of Inversions

Data Structures and Algorithms 2016-12-28 v1

Abstract

Counting inversions is a classic and important problem in databases. The number of inversions, KK^*, in a list L=(L(1),L(2),,L(n))L=(L(1),L(2),\ldots,L(n)) is defined as the number of pairs i<ji < j with L(i)>L(j)L(i) > L(j). In this paper, new results for this problem are presented: (1) In the I/O-model, an adaptive algorithm is presented for calculating KK^{*}. The algorithm performs O(NB+NBlogM/B(KNB))O(\frac{N}{B}+ \frac{N}{B}\log_{M/B}(\frac{K^*}{NB})) I/Os. When K=O(NM)K^{*}=O(NM), then the algorithm takes only O(NB)O(\frac{N}{B}) I/Os. This algorithm can be modified to match the state of the art for the comparison based model and the RAM model. (2) In the RAM model, a linear-time algorithm is presented to obtain a tight estimate of KK^*; specifically, a value which lies with high probability in the range [(1logNN1/4)K,(1+logNN1/4)K][(1-\frac{\log N}{N^{1/4}})K^*,(1+\frac{\log N}{N^{1/4}})K^*]. The state of the art linear-time algorithm works for the special case where LL is a permutation, i.e., each L(i)L(i) is a distinct integer in the range [1,N][1,N]. In this paper, we handle a general case where each L(i)L(i) is a real number.

Keywords

Cite

@article{arxiv.1612.08097,
  title  = {New Results for Adaptive and Approximate Counting of Inversions},
  author = {Saladi Rahul},
  journal= {arXiv preprint arXiv:1612.08097},
  year   = {2016}
}