Abstract
In this paper, we introduce a new randomized, partition-based algorithm for the problem of computing the number of inversion pairs in an unsorted array of n numbers. The algorithm runs in expected time O(n · log n) and uses O(n) extra space. The expected time analysis of the new algorithm is different from the analyses existing in the literature, in that it explicitly uses inversion pairs. The problem of determining the inversion pair cardinality of an array finds applications in a number of design domains, including but not limited to real-time scheduling and operations research. At the heart of our algorithm is a new inversion pair conserving partition procedure that is different from existing partition procedures such as Hoare-partition and Lomuto-partition. Although the algorithm is not fully adaptive, we believe that it is the first step towards the design of an adaptive, partition-based sorting algorithm whose running time is proportional to the number of inversion pairs in the input.
Similar content being viewed by others
References
Bistarelli S, Gennari R, Rossi F (2000) Constraint propagation for soft constraints: generalization and termination conditions. In: CP, pp 83–97
Bentley JL, McIlroy MD (1993) Engineering a sort function. Softw Practice Exp 23(11): 1249–1265
Brown MR, Tarjan RE (1980) Design and analysis of data structures for representing sorted lists. SIAM J Comput 9: 594–614
Burge WH (1958) Sorting, trees and measures of order. Inf Control 1(3): 181–197
Cook CR, Kim DJ (1980) Best sorting algorithms for nearly linearly sorted lists. Commun ACM 23: 620–624
Cormen TH, Leiserson CE, Rivest RL (1992) Introduction to algorithms, 2nd edn. MIT Press and McGraw-Hill Book Company, Boston
Cormen TH, Leiserson CE, Rivest RL, Stein C (2001) Introduction to algorithms. MIT Press, New York
Demtrescu C (2004) A new approach to dynamic all pairs shortest paths. J ACM 51(6): 968–992
Estivill-Castro V, Wood D (1992) A survey of adaptive sorting algorithms. ACM Comput Surv 24(4): 441–476
Guibas LJ, McCreight EM, Plass MF (1977) A new represenation of linear lists. In: Symposium on the theory of computing, pp 49–60
Gonzalez O, Shrikumar H, Ramamritham K, Stankovic J (1997) Adaptive fault tolerance and graceful degradation under dynamic hard real-time scheduling. In: Real-time systems symposium, San Francisco
Herrmann C (1994) Vbr video in atm without frame buffering: influence of a periodic correlation function on qos parameters. In: Modelling and evaluation of ATM networks, pp 14–31
Hoare CAR (1961) Quicksort. Commun ACM 4(7): 321
Kiwiel KC (2003) Partitioning schemes for quicksort and quickselect, Warsaw
Kalyanasundaram, Pruhs (2000) Fault-tolerant real-time scheduling. ALGRTHMICA: Algorithmica, 28
Mannila H (1985) Measures of presortedness and optimal sorting algorithms. IEEE Trans Comput 34(4): 318–325
McIlroy MD (1999) A killer adversary for quicksort. Softw Practice Exp 29(4): 341–344
Mehlhorn K (1984) Data structures and algorithms, vol I: Sorting and Searching. EATCS monographs on Theoretical Computer Science. Springer, Heidelberg
Martínez C, Roura S (2001) Optimal sampling strategies in quicksort and quickselect. SIAM J Comput 31(3): 683–705
Petersson O (1990) Adaptive sorting. PhD Thesis, Lund University, Lund, Sweden
Pradhan DK (1986) Fault-tolerant computing: theory and techniques. Prentice Hall, Englewood Cliffs, NJ
Stankovic J (1988) Misconceptions about real-time computing. IEEE Comput 21(10):10–19
Stankovic JA (1988) Real-time computing systems: the next generation. In: Stankovic JA, Ramamritham K (eds) Tutorial: hard real time systems. IEEE 14:38
Takoka T (2008) Minimal mergesort (manuscript)
van Emden MH (1970) Algorithms 402: Increasing the efficiency of quicksort. Commun ACM 13(11): 693–694
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
About this article
Cite this article
Subramani, K. Computing inversion pair cardinality through partition-based sorting. Computing 83, 41–54 (2008). https://doi.org/10.1007/s00607-008-0011-x
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00607-008-0011-x