All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
Rotating an array (Posted on 2004-04-19) Difficulty: 2 of 5
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.

See The Solution Submitted by e.g.    
Rating: 4.0000 (13 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
re: 10 step method | Comment 9 of 26 |
(In reply to 10 step method by logischer Verstand)

logicscher's solution is "correct" in this specific case, but I think the problem is asking for the general case with an offset of N and an array of M elements.  (In the problem, N=4, and M=11.)

Please show a general algorithm that solves it in no more than M-1 flips!

  Posted by SilverKnight on 2004-04-19 18:02:43

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (14)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information