Re: "Interleave" permutation algorithm?
- From: Willem <willem@xxxxxxxx>
- Date: Wed, 26 Aug 2009 07:25:12 +0000 (UTC)
robertwessel2@xxxxxxxxx wrote:
) One way:
)
) e = 2; // Start with the first out of place element (the second)
) t = element[e];
) Loop:
) compute e2 = where element[e] *should* go
) if e == e2 then element[e2] = t, done
) swap t, element[e2]
) e = e2;
)
)
) That generalizes to general reordering if you search through the array
) looking for out of place elements, rather than just assuming it's only
) one group starting with the second element.
You'll have to generalize then, because the permutation the OP wants
is not comprised of a single group.
(In the case of 0123456789, the 3 and 6 are exchanged for example.)
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
.
- References:
- "Interleave" permutation algorithm?
- From: mike3
- Re: "Interleave" permutation algorithm?
- From: mike3
- Re: "Interleave" permutation algorithm?
- From: robertwessel2@xxxxxxxxx
- "Interleave" permutation algorithm?
- Prev by Date: *****Language Institutes *******
- Next by Date: Re: "Interleave" permutation algorithm?
- Previous by thread: Re: "Interleave" permutation algorithm?
- Next by thread: Re: "Interleave" permutation algorithm?
- Index(es):