To sort a permutation using prefix reversals, work backwards through final positions. On an active prefix of length , find its largest value. If it is already at the final position, shorten the active prefix. Otherwise move it to the front with one reversal if necessary, then reverse the entire active prefix to put it last. Already settled suffix positions are untouched.
The settled suffix is a loop invariant, and active-prefix length decreases to one. This proves reachability of the identity permutation in at most nontrivial flips. The construction is a finite upper bound, not a promise of minimum length; breadth-first search can find the minimum for small instances.
Articles by others on the same topic
There are currently no matching articles.