Abstract
We present two algorithms that are near optimal with respect to the number of inversions present in the input. One of the algorithms is a variation of insertion sort, and the other is a variation of merge sort. The number of comparisons performed by our algorithms, on an input sequence of length n that has I inversions, is at most \(n\,{\rm log}_{2} (\frac{I}{n} + 1) + O(n)\) . Moreover, both algorithms have implementations that run in time \(O(n\,{\rm log}_{2} (\frac{I}{n} + 1)\,+\,n)\) . All previously published algorithms require at least \(cn\,{\rm log}_{2} (\frac{I}{n} + 1)\) comparisons for some c > 1.
Similar content being viewed by others
References
Andersson, A., Lai, T.W.: Fast updating of well-balanced trees. In: Proceedings of Scandinavian Workshop on Algorithm Theory, pp. 111–121. Springer, Heidelberg (1990)
Brown M. and Tarjan R. (1980). Design and analysis of data structures for representing sorted lists. SIAM J. Comput. 9: 594–614
Bentley J. and Yao A. (1976). An almost optimal algorithm for unbounded searching. Inf. Process. Lett. 5(3): 82–87
Carlsson S., Levcopoulos C. and Petersson O. (1993). Sublinear merging and natural Mergesort. Algorithmica 9: 629–648
Cole R. (2000). On the dynamic finger conjecture for splay trees. Part II: The proof. SIAM J. Comput. 30: 44–85
Elmasry, A.: Priority Queues, Pairing and Adaptive Sorting. 29th ICALP. LNCS, vol. 2380, pp. 183–194 (2002)
Estivill-Castro V. (1992). A survey of adaptive sorting algorithms. ACM Comput. Surv. 24(4): 441–476
Estivill-Castro V. and Wood D. (1989). A new measure of presortedness. Inf. Comput. 83: 111–119
Fredman M. (1976). How good is the information theory bound in sorting?. Theor. Comput. Sci. 1: 355–361
Guibas L., McCreight E., Plass M. and Roberts J. (1977). A new representation of linear lists. ACM Symp. Theory Comput. 9: 49–60
Knuth, D.: The Art of Computer Programming: Sorting and Searching, vol. III, 2nd edn. Addison-wesley (1998)
Levcopoulos C. and Petersson O. (1991). Splitsort—an adaptive sorting algorithm. Inf. Process. Lett. 39: 205–211
Levcopoulos C. and Petersson O. (1993). Adaptive heapsort. J. Algorithms 14: 395–413
Levcopoulos C. and Petersson O. (1994). Sorting shuffled monotone sequences. Inf. Comput. 112: 37–50
Levcopoulos C. and Petersson O. (1996). Exploiting few inversions when sorting: Sequential and parallel algorithms. Theor. Comput. Sci. 163: 211–238
Mannila H. (1985). Measures of presortedness and optimal sorting algorithms. IEEE Trans. Comput. C-34: 318–325
Mehlhorn K. (1984). Data Structures and Algorithms. Sorting and Searching, vol. 1. Springer, Berlin
Mehlhorn, K.: Sorting presorted files. In: Proceedings Of the 4th GI Conference on Theory of Computer Science. LNCS, vol. 67, pp. 199–212 (1979)
Moffat, A., Petersson, O., Wormald, N.: A Tree-based Mergesort. Acta Informatica, pp. 775–793. Springer, Heidelberg (1998)
Petersson O. and Moffat A. (1995). A framework for adaptive sorting. Discrete Appl. Math. 59: 153–179
Sleator D. and Tarjan R. (1985). Self-adjusting binary search trees. J. ACM 32(3): 652–686
Author information
Authors and Affiliations
Corresponding author
Additional information
M. L. Fredman was supported in part by NSF grant CCR-9732689.
Rights and permissions
About this article
Cite this article
Elmasry, A., Fredman, M.L. Adaptive sorting: an information theoretic perspective. Acta Informatica 45, 33–42 (2008). https://doi.org/10.1007/s00236-007-0061-0
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00236-007-0061-0