I didn't understand what is meant by "algorithm".... perhaps it is better to give some examples. Let's take Bianca's initial example: modulating from C major to E major.
One of the chord sequences (or techniques or "algorithms" if you will...) to connect these two distant keys is the enharmonic spelling of the dominant seventh.
1) Start from C major
2) transform the chord on the I degree into a dominant chord (C E G Bb)
3) enharmonically alter the seventh so that it becomes an altered sixth (C E G A#). At the moment of enharmonic alteration, we have already passed to the new key; from now on, we will reason in E.
4) the altered VI chord resolves to the V degree harmonized with 4,6 (i.e., II rev) (B D# F# B), note the A# resolving to B
5) V degree in 3,5 (B D# F#), eventually with the seventh
6) resolution to the E major chord (I degree of the new key).
This is the algorithm, understood as a process for solving a specific question; now, to generalize, we can say that with this technique of enharmonic spelling of the dominant seventh, one can modulate to keys that are a major third, a major sixth, a semitone lower, and some other keys away (I don't remember all the possibilities precisely right now).
What more is there to know about this...?