Counting inversions is a classic and important problem in databases. The number of inversions, , in a list is defined as the number of pairs with . In this paper, new results for this problem are presented: (1) In the I/O-model, an adaptive algorithm is presented for calculating . The algorithm performs $O(\frac{N}{B}+ \frac{N}{B}\log_{M/B}(\frac{K^}{NB}))K^{}=O(NM)$, then the algorithm takes only 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 ; specifically, a value which lies with high probability in the range . The state of the art linear-time algorithm works for the special case where is a permutation, i.e., each is a distinct integer in the range . In this paper, we handle a general case where each is a real number.

生成讲解博客的中文版本

生成AI智能校验的中文版本