# Topic Q - Simple Algorithms
# Swapping
The simplest of all algorithms is the swap, where you basically have two variables or objects whose values you want to switch. The key requirement for a swap, of course, is that the data types of the two variables/objects are the same.
For example, if you have two strings, varA
and varB
, with the values of "Matt" and "Mallory" respectively, and you want to swap the two values, you would need to introduce an additional variable to temporarily hold one of the values.
Examples →