Copyright © 2004 Elsevier Inc. All rights reserved.
Permuting in place: analysis of two stopping rules
Received 2 September 2002.
References and further reading may be available for this article. To view references and further reading you must purchase this article.
Abstract
Permuting in place has been first analyzed by Knuth. It uses the cycle structure of the permutation. The elements of an array to be permuted are only moved when one sees a cycle leader (smallest element in its cycle). So the essential part of such an algorithm is to test an element i about whether it is a cycle leader.
Recently, Keller [Inform. Process. Lett. 81 (2002) 119–125] introduced two stopping rules: “If the last cycle leader has been detected, all elements have been moved, and no further tests are necessary” (heuristic 1), respectively “If only r elements have not been moved, then proceeding along a cycle is only useful for r steps” (heuristic 2).
We analyze the average costs of these modifications applied to the standard algorithm of Knuth; they are (n+2)Hn−5n/2−1/2
nlogn and respectively ((2n+1)/4)H
(n+1)/2
+(1/2)H2
(n+1)/2
−(1/2)(
(n+1)/2
−
n/2
)−(n+1)/2
(n/2)logn, as opposed to (n+1)Hn−2n
nlogn in the classical case.
Author Keywords: Analysis of algorithms; Permuting in place; Knuth's parameter a; Harmonic numbers







E-mail Article
Add to my Quick Links

Cited By in Scopus (1)

1 we have





