Prefix and Suffix Reversals on Strings
Résumé
The Sorting by Prefix Reversals problem consists in
sorting the elements of a given permutation π with a minimum number
of prefix reversals, i.e. reversals that always imply the leftmost element
of π. A natural extension of this problem is to consider strings (in
which any letter may appear several times) rather than permutations. In
strings, three different types of problems arise: grouping (starting from a
string S, transform it so that all identical letters are consecutive), sorting
(a constrained version of grouping, in which the target string must be
lexicographically ordered) and rearranging (given two strings S and T,
transform S into T). In this paper, we study these three problems, under
an algorithmic viewpoint, in the setting where two operations (rather
than one) are allowed: namely, prefix and suffix reversals - where a suffix
reversal must always imply the rightmost element of the string. We
first give elements of comparison between the “prefix reversals only” case
and our case. The algorithmic results we obtain on these three problems
depend on the size k of the alphabet on which the strings are built. In
particular, we show that the grouping problem is in P for k ∈ [2; 4] and
when n − k = O(1), where n is the length of the string. We also show
that the grouping problem admits a PTAS for any constant k, and is
2-approximable for any k. Concerning sorting, it is in P for k ∈ [2; 3],
admits a PTAS for constant k, and is NP-hard for k = n. Finally, concerning
the rearranging problem, we show that it is NP-hard, both for
k = O(1) and k = n. We also show that the three problems are FPT
when the parameter is the maximum number of blocks over the source
and target strings.