Implement GreedySorting to Sort a Permutation by Reversals solved by 555

Jan. 21, 2014, 12:05 a.m. by Rosalind Team

Implement GreedySorting

Given: A signed permutation P.

Return: The sequence of permutations corresponding to applying GreedySorting to P, ending with the identity permutation.

Sample Dataset

(-3 +4 +1 +5 -2)

Sample Output

(-1 -4 +3 +5 -2)
(+1 -4 +3 +5 -2)
(+1 +2 -5 -3 +4)
(+1 +2 +3 +5 +4)
(+1 +2 +3 -4 -5)
(+1 +2 +3 +4 -5)
(+1 +2 +3 +4 +5)

Extra Dataset

Please login to solve this problem.