Exchange two stored values while preserving all others. For an array, a temporary value implements x := a[i]; a[i] := a[j]; a[j] := x. For distinct indices this uses two element reads and two element writes. The operation is an involution, and its permutation is a transposition.
Exchange two equally long disjoint segments of an array, preserving the order within each segment. Applying one swap at each corresponding offset exchanges length- blocks in swaps and constant auxiliary storage. Disjointness ensures that an earlier swap does not overwrite an original value needed by a later pair.

Articles by others on the same topic (0)

There are currently no matching articles.