Every permutation can be decomposed into a product of transpositions (cycles with only two elements). The number of transpositions is not unique, but for any permutation the number will be either odd or even. The signature of a permutation is equal to:
The signature of a cycle of size k is: (−1)k+1.
The signature command computes the signature of a permutation.
signature([3,4,5,2,0,1]) |
|