Comment on Swapping two blocks of memory inside a larger block, in constant memoryComments−HarHarVeryFunny8moCouldn't this be done in 2 rotates rather than 3 :A B C D EA C B D E -- after rotate B, CA D C B E -- after rotate C-B, DComplexity would seem to be the same as the reverse method, since every element in the original B-D range is getting moved twice.
Comments
Couldn't this be done in 2 rotates rather than 3 :
A B C D E
A C B D E -- after rotate B, C
A D C B E -- after rotate C-B, D
Complexity would seem to be the same as the reverse method, since every element in the original B-D range is getting moved twice.