I have an array such as
A-B-C-D-E-F-G-H-I-J-K
I want to rotate it N places to the right; for example, if N=3, the array should end
I-J-K-A-B-C-D-E-F-G-H
Assume that the only available operation is a FLIP method that can invert any portion of the array. For example, applied to the original array FLIP(3,6) would produce A-B-F-E-D-C-G-H-I-J-K.
This answer is assuming the answer to my question is "yes."
Start: A-B-C-D-E-F-G-H-I-J-K
1. FLIP(1,9)=I-B-C-D-E-F-G-H-A-J-K
2. FLIP(2,10)=I-J-B-C-D-E-F-G-H-A-B-K
3. FLIP(3,11)=I-J-K-D-E-F-G-H-A-B-C
4. FLIP(8,11)=I-J-K-D-E-F-G-C-A-B-H
5. FLIP(7,10)=I-J-K-D-E-F-B-C-A-G-H
6. FLIP(6,9)=I-J-K-D-E-A-B-C-F-G-H
7. FLIP(5,8)=I-J-K-D-C-A-B-E-F-G-H
8. FLIP(4,7)=I-J-K-B-C-A-D-E-F-G-H
9. FLIP(4,6)=I-J-K-A-C-B-D-E-F-G-H
10. FLIP(5,6)=
I-J-K-A-B-C-D-E-F-G-H I am working on trying to possibly reduce it by one or two more steps
Edited on April 19, 2004, 6:15 pm