New Results for Adaptive and Approximate Counting of Inversions

Counting inversions is a classic and important problem in databases. The number of inversions, $K^*$, in a list $L=(L(1),L(2),\ldots,L(n))$ is defined as the number of pairs $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 $K^{*}$. The algorithm performs $O(\frac{N}{B}+ \frac{N}{B}\log_{M/B}(\frac{K^*}{NB}))$ I/Os. When $K^{*}=O(NM)$, then the algorithm takes only $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 $K^*$; specifically, a value which lies with high probability in the range $[(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 $L$ is a permutation, i.e., each $L(i)$ is a distinct integer in the range $[1,N]$. In this paper, we handle a general case where each $L(i)$ is a real number.

[1]  Amr Elmasry,et al.  Counting inversions adaptively , 2015, Inf. Process. Lett..

[2]  Paul F. Dietz Optimal Algorithms for List Indexing and Subset Rank , 1989, WADS.

[3]  Donald E. Knuth,et al.  The art of computer programming, volume 3: (2nd ed.) sorting and searching , 1998 .

[4]  Ravi Kumar,et al.  Approximate counting of inversions in a data stream , 2002, STOC '02.

[5]  Yijie Han,et al.  Integer sorting in O(n/spl radic/(log log n)) expected time and linear space , 2002, The 43rd Annual IEEE Symposium on Foundations of Computer Science, 2002. Proceedings..

[6]  Yijie Han,et al.  Deterministic sorting in O(nloglogn) time and linear space , 2004, J. Algorithms.

[7]  Timothy M. Chan Optimal output-sensitive convex hull algorithms in two and three dimensions , 1996, Discret. Comput. Geom..

[8]  Anupam Gupta,et al.  Counting inversions in lists , 2003, SODA '03.

[9]  Timothy M. Chan,et al.  Counting inversions, offline orthogonal range counting, and related problems , 2010, SODA '10.

[10]  Derick Wood,et al.  A survey of adaptive sorting algorithms , 1992, CSUR.

[11]  Moni Naor,et al.  Rank aggregation methods for the Web , 2001, WWW '01.

[12]  Donald E. Knuth,et al.  The art of computer programming: sorting and searching (volume 3) , 1973 .

[13]  Jeffrey Scott Vitter,et al.  Efficient 3-D range searching in external memory , 1996, STOC '96.

[14]  K. Weihrauch Theoretical Computer Science 4th GI Conference , 1979, Lecture Notes in Computer Science.

[15]  Mikkel Thorup,et al.  On Adaptive Integer Sorting , 2004, ESA.

[16]  Timothy M. Chan,et al.  Optimal halfspace range reporting in three dimensions , 2009, SODA.

[17]  Kurt Mehlhorn Sorting Presorted Files , 1979, Theoretical Computer Science.

[18]  R. Graham,et al.  Spearman's Footrule as a Measure of Disarray , 1977 .

[19]  Jirí Matousek,et al.  Reporting Points in Halfspaces , 1992, Comput. Geom..

[20]  Alok Aggarwal,et al.  The input/output complexity of sorting and related problems , 1988, CACM.

[21]  Ola Petersson,et al.  Approximate Indexed Lists , 1998, J. Algorithms.