An Analysis of Two In-Place Array Rotation Algorithms
This paper presents a complexity analysis of two STL in-place rotation algorithms. If an array of n elements is rotated to the right Δ positions, the first STL version, which uses forward iterators, uses n - gcd(n, Δ) swaps, while the second version, which uses random access iterators, uses only n+gcd(n, Δ) array element movements. This paper also proves the optimality of the second version. A performance comparison is included.