Block swap algorithms

Block swap algorithms swap two elements of an array in computer algorithms. It is simple to swap two non-overlapping regions of an array of equal size. However, it is not simple to swap two non-overlapping regions of an array in-place that are next to each other, but are of unequal sizes. Three algorithms are known to accomplish this: Bentley's Juggling, Gries-Mills, and Reversal. All three algorithms are linear time O(n), (see Time complexity).

Block swap algorithms

Block swap algorithms swap two elements of an array in computer algorithms. It is simple to swap two non-overlapping regions of an array of equal size. However, it is not simple to swap two non-overlapping regions of an array in-place that are next to each other, but are of unequal sizes. Three algorithms are known to accomplish this: Bentley's Juggling, Gries-Mills, and Reversal. All three algorithms are linear time O(n), (see Time complexity).