Anonymous user
Talk:Factorial base numbers indexing permutations of a collection: Difference between revisions
Talk:Factorial base numbers indexing permutations of a collection (view source)
Revision as of 10:47, 19 January 2019
, 5 years ago→Why not using the inverse of Knuth_shuffle: new section
(→Why not using the inverse of Knuth_shuffle: new section) |
|||
Line 78:
=============================================================================================================================
::Thanks--[[User:Nigel Galloway|Nigel Galloway]] ([[User talk:Nigel Galloway|talk]]) 11:21, 10 December 2018 (UTC)
== Why not using the inverse of [http://rosettacode.org/wiki/Knuth_shuffle Knuth_shuffle] ==
this has the same factorial base number, but one has to do only length-1 swaps instead of rotation.
It ist easy to create a map between source and goal arrangement.
<pre>
source 1.3.2.0 with value,indices (0,3|1,0|2,1|3,1)
goal 0,1,2,3 with value,indices (0,0|1,1|2,2|3,3)
start index = 0
first swap 0 <-> 1 => index 0 <-> 3 -> update Value,Indices for swapped values ->
(Swap Index = 3 out of [0..3])
source 0.3.2.1 with value,indices (0,0|1,3|2,2|3,1)
index++ => 1
swap 3 <-> 1 => index 1 <-> 3
(Swap Index = 3 out of [index..3])
source 0.1.2.3 with value,indices (0,0|1,1|2,2|3,3)
index++ => 2
index 2 = index of value -> no swap;
source 0.1.2.3 with value,indices (0,0|1,1|2,2|3,3)
index++ => 3
index 3 = index of value -> no swap;
source 0.1.2.3 with value,indices (0,0|1,1|2,2|3,3)
</pre>
I see that the advantage of the rotation is the lexicographical order of generating the permutations, but what is it good for?
|