I don't (quite) understand the question. You are showing the "Classic" Tower of Hanoi problem, but with only three disks (represented by the numbers 1, 2, and 3). The rules are the same -- you have N disks and three pegs. The disks start out all placed on, say, Peg 1, and the task is to move them all to, say, Peg 2, subject to the following rules:
- You can only remove the top disk from a peg.
- You must place the removed disk on a peg such that it is the smallest disk on the peg (thus maintaining the "invariant" that all disks on all pegs are in "size order").
The Solution is a classic example of Recursion.
Bob Schor