RosettaCodeData/Task/Permutations-by-swapping/00DESCRIPTION

24 lines
1.2 KiB
Text
Raw Permalink Normal View History

2016-12-05 22:15:40 +01:00
;Task:
2015-11-18 06:14:39 +00:00
Generate permutations of n items in which successive permutations differ from each other by the swapping of any two items.
2016-12-05 22:15:40 +01:00
2015-11-18 06:14:39 +00:00
Also generate the sign of the permutation which is +1 when the permutation is generated from an even number of swaps from the initial state, and -1 for odd.
2016-12-05 22:15:40 +01:00
2015-11-18 06:14:39 +00:00
Show the permutations and signs of three items, in order of generation ''here''.
2013-04-10 23:57:08 -07:00
Such data are of use in generating the [[Matrix arithmetic|determinant]] of a square matrix and any functions created should bear this in mind.
Note: The SteinhausJohnsonTrotter algorithm generates successive permutations where ''adjacent'' items are swapped, but from [[wp:Parity_of_a_permutation#Example|this]] discussion adjacency is not a requirement.
2016-12-05 22:15:40 +01:00
2013-04-10 23:57:08 -07:00
;References:
* [[wp:SteinhausJohnsonTrotter algorithm|SteinhausJohnsonTrotter algorithm]]
* [http://www.cut-the-knot.org/Curriculum/Combinatorics/JohnsonTrotter.shtml Johnson-Trotter Algorithm Listing All Permutations]
2015-11-18 06:14:39 +00:00
* [http://stackoverflow.com/a/29044942/10562 Correction to] Heap's algorithm as presented in Wikipedia and widely distributed.
2017-09-23 10:01:46 +02:00
* [http://www.gutenberg.org/files/18567/18567-h/18567-h.htm#ch7] Tintinnalogia
2013-04-10 23:57:08 -07:00
2016-12-05 22:15:40 +01:00
2018-06-22 20:57:24 +00:00
;Related tasks:
2016-12-05 22:15:40 +01:00
*   [[Matrix arithmetic]]
2017-09-23 10:01:46 +02:00
*   [[Gray code]]
2016-12-05 22:15:40 +01:00
<br><br>