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.
(In reply to
question for e.g. by logischer Verstand)
Yes, that's exactly what he means to ask.
You have available the basic programmatic operators... for, while...
do, do... while, repeat... until, if... then, integer variables with
basic mathematical operators, and arrays (which includes an index
method, of course, such as Characters[5] meaning the 'E' in the first
array, assuming a 1-based array).
I'm sure you are welcome to use any language you'd like... C/C++, Pascal, Basic, Fortran, COBOL, etc....
And I'll bet an algorithm in pseudocode or even english will suffice (with proper precision).
- SK