Definition:Replacement Operation/Examples
Jump to navigation
Jump to search
Examples of use of Replacement Operation
Exchange Operation as Replacement Operations
Let $x$ and $y$ be variables whose values are to be exchanged.
The exchange operation on $x$ and $y$ can be implemented using replacement operations.
Let $t$ be a third variable which has been established for this purpose.
Then the sequence of replacement operations:
- $t \gets x$
- $x \gets y$
- $y \gets t$
performs the task.
Rearrangement Operation as Replacement Operations
Let $\left({a, b, c, d}\right)$ be an ordered quadruple consisting of four variables whose values are to be rearranged into the order $\left({b, c, d, a}\right)$.
This can be implemented using replacement operations.
Let $t$ be a new variable which has been established for this purpose.
Then the sequence of replacement operations:
- $t \gets a$
- $a \gets b$
- $b \gets c$
- $c \gets d$
- $d \gets t$
performs the task.