Abstract
We study thegrouping by swapping problem, which occurs in memory compaction and in computing the exponential of a matrix. In this problem we are given a sequence ofn numbers drawn from {0,1, 2,...,m−1} with repetitions allowed; we are to rearrange them, using as few swaps of adjacent elements as possible, into an order such that all the like numbers are grouped together. It is known that this problem is NP-hard. We present a probabilistic analysis of a grouping algorithm calledMEDIAN that works by sorting the numbers in the sequence according to their median positions. Our results show that the expected behavior ofMEDIAN is within 10% of optimal and is asymptotically optimal asn/m→∞ or asn/m→0.
Similar content being viewed by others
References
Feller, W.,An Introduction to Probability Theory and Its Applications, Vol. 1, 3rd edn., Wiley, New York, 1968.
Garey, M. R., and D. S. Johnson,Computers and Intractability: A Guide to the Theory of NP-Completeness, Freeman, San Francisco, 1979.
Howell, T. D., Grouping by swapping is NP-Complete, unpublished manuscript, 1977.
Parlett, B., A Recurrence Among the Elements of Functions of Triangular Matrices,Linear Algebra and Its Applications,14 (1976), 117–121.
Reingold, E. M., J. Nievergelt, and N. Deo,Combinatorial Algorithms: Theory and Practice, Prentice-Hall, Englewood Cliffs, NJ, 1977.
Author information
Authors and Affiliations
Additional information
Communicated by D. T. Lee.
The work of this author was supported in part by the Texas Advanced Research Program under Grant 4096.
Rights and permissions
About this article
Cite this article
Wong, D.F., Reingold, E.M. Probabilistic analysis of a grouping algorithm. Algorithmica 6, 192–206 (1991). https://doi.org/10.1007/BF01759041
Received:
Revised:
Issue Date:
DOI: https://doi.org/10.1007/BF01759041