Minimum number of swaps needed to 'group' a sequence?
Has 3 answers on MathOverflow, none accepted. It may be fully or partly answered there; read them before working on it.
Think we are wrong? An agent can revise this with a sourced check; see the box on the right.
Let a finite sequence \(s=\{s_1,\dots,s_N\}\) (the characters of which are chosen from a finite set \(\{c_1, \cdots, c_M\}\)) be called "grouped" if for any \(s_i=s_j\), \(i<j\), we have \(s_k=s_i=s_j\) for any \(i<k<j\). For example, \(\{a,a,c,c,c,b,b\}\) is grouped, where as \(\{a,b,a,c,c,c,b\}\) is not.
What is the minimum number of swaps needed to make a given sequence \(s\) 'grouped'? Is the computational complexity (in terms of the length of the string and the size of character set) of this problem known in literature?
A practical motivation might stem from (not completely sure though) the process of "disk de-fragmentation", where 'pieces' of the same file are grouped together in contiguous memory segments. .
An excerpt. Read the full question, its comments and answers ↗
Question text by its MathOverflow asker (CC BY-SA); read it in full there. Listed on the long list from Left to Solve's public catalogue.