4

Let's define a distance between two permutation of length $N$: it is the minimum steps to change one to be another. "A step of change" means that exchanging any two elements' location.

For example, series $\{1,2,3\}$ can be changed into $\{2,1,3\}$ in one step, by exchanging the location of $1$ and $2$. So it means

$$\text{d}(\{1,2,3\},\{2,1,3\}) = 1$$

$\text{d}$ means distance. So, we can easily get that $\text{d}(\{1,2,3\},\{3,1,2\})$ is $2$ and so on.

But while $N$ is big enough, how can I get the distance between two arbitrary series?

SandyX
  • 301
  • I don't think the term "series" fits this question. The sequences-and-series tag is not really relevant. What about "numbers"? – rubik Aug 26 '15 at 09:05
  • @rubik yes,I will change it – SandyX Aug 26 '15 at 09:08
  • I also meant the words in the question. Defining a distance between two "numbers" sounds good to me. – rubik Aug 26 '15 at 09:10
  • @rubik Well, I suppose you say that is a number, while I just represent it by its indices. It seems cause ambiguity. I will change it. – SandyX Aug 26 '15 at 09:14
  • 2
    See http://stackoverflow.com/questions/7797540/counting-the-swaps-required-to-convert-one-permutation-into-another. – lhf Aug 26 '15 at 11:05
  • 1
    It seems in the literature, there are names for this distance. See Cayley's distance. http://mathoverflow.net/questions/98546/hamming-distance-approximates-cayley-distance-on-permutations-citation-wanted – Sergio Parreiras Oct 26 '16 at 18:00

2 Answers2

6

Instead of "series" the mathematical term in this case is a permutation. Mathematically speaking you want to determine the following: For two permutations $\pi$, $\tau$ you want to find the minimal number $n$ of transpositions $\sigma_i$ so that $$\pi = \sigma_1 \circ \ldots \circ \sigma_n \circ \tau.$$ Equivalently one might ask for the minimal $n$ for which $$\pi \tau^{-1} = \sigma_1 \circ \ldots \circ \sigma_n.$$

Now you can decompose the permutation $\pi \tau^{-1}$ into disjoint cycles. I don't have a rigorous proof, but $n$ should be the sum of the lengths of all cycles, minus the number of cycles [or equivalently: sum up all the cycle-lengths after substracting $1$ from every length].

Edit: If the permutation consists of $k$ elements, then this number is actually the difference between $k$ and the number of cycles in the cycle-representation of the permutation. Now observe that with a transposition you can only increase or decrease this number by $1$ and that the identity is the only permutation with $k$ cycles. This should yield a rigorous proof of my statement.

Dominik
  • 19,963
  • I just think in your description, 'transpositions' means 'exchanging two consecutive elements in a permutation' instead of 'exchanging any two elements in a permutation', the last one is what exactly I mean. – SandyX Aug 26 '15 at 11:48
  • A transposition is any permutation that switches two elements and keeps the rest fixed - these elements don't need to be consecutive. The permutation that maps $1 \mapsto 3, 3 \mapsto 1, 2 \mapsto 2$ is a transposition. – Dominik Aug 26 '15 at 11:51
  • I understand your idea, and I believe it is right. BTW, can you point out where I can find the meaning of the notation $\pi\tau^{-1}$ – SandyX Aug 26 '15 at 12:07
  • The set of all bijections on a set of size $k$ has a group-structure if you choose the operation to be the composition of functions. This group is called the symmetric group on $k$ elements. $\tau^{-1}$ is the inverse of $\tau$ with respect to this operation and $\pi \tau^{-1}$ is the composition of $\pi$ and $\tau^{-1}$. While I don't have a specific source for you, every book about algebra should contain a chapter about symmetric groups. – Dominik Aug 26 '15 at 12:14
2

Finding the transposition distance is an NP-hard problem. This is proved in this paper:

Laurent Bulteau, Guillaume Fertin, and Irena Rusu
Sorting by Transpositions is Difficult
SIAM J. Discrete Math., 26(3), 1148–1180 (2012).
DOI: 10.1137/110851390, arXiv:1011.1157.

NP-hard means that most probably only approximation algorithms can be efficient for large $N$. See this paper for instance:

Ulisses Dias, Zanon Dias
Heuristics for the transposition distance problem
Journal of Bioinformatics and Computational Biology, 11(5), 1350013 (2013).
DOI: 10.1142/S0219720013500133.

lhf
  • 216,483
  • Thanks. But I find the little difference between the two problem: mine is able to exchange any two elements, while the problem in the paper is about the consecutive sequences. – SandyX Aug 26 '15 at 11:02
  • 1
    You're right, sorry for the noise. – lhf Aug 26 '15 at 11:04
  • Using a specific terminology, you are referring to "Kendall distance" whereas the issue of the OP is about "Cayley distance". – Jean Marie Mar 24 '22 at 09:02