Tower of Hanoi Algorithm I read many articles about the "Towers of Hanoi" algorithm, but i couldn't see any relation to computer science or something else? Is it used somewhere to describe a special problem? 
 A: The Tower of Hanoi problem was invented as a mathematical puzzle by
mathematician Edouard Lucas in 1883. As far as I know, its popularity in computer science
comes from the fact that it illustrates simply the power of recursive
algorithms.
Iterative versions of the algorithm are somewhat awkward to explain and
understand, The recursive algorithm is very simple, and intuitively
obvious: to move n discs from peg x to peg y, just move the n-1 smaller discs to peg z (the remaining peg), move the largest disc to peg y, then move th n-1 smaller discs to peg y.
Teaching recursion is pretty basic today, but that was not always
true.  I remember a discussion with an engineer in a research lab in
the 1970s.  He thought our program (actually denotational semantics)
was wrong because a function was calling itself. But his excuse was
that he knew only Fortran and assembly language, which did not allow
recursion because they had statically allocated memory.
The relation between the discs positions and the move number in binary notation is sometimes analyzed. But I think this is just a minor exercise, not the real incentive for looking at the puzzle.
A: Tower of Hanoi is a form of a mathematical puzzle and it's pretty popular in the field of mathematics and computer science. Why is it popular in computer science? Like "babou" explained above, the popularity of the Tower of Hanoi puzzle is basically due to the easy explanation of recursive algorithm.
To write an algorithm for Tower of Hanoi, first we need to learn how to solve this problem with lesser amount of disks, say → 1 or 2. We mark three towers with name, source,destination and aux (only to help moving disks). If we have only one disk, then it can easily be moved from source to destination peg.
According to the image below:
n -> Larger disk,
n-1 -> Smaller disk
Image-> The Tower of Hanoi 
If we have 2 disks −
First we move the smaller one (top) disk to aux peg
Then we move the larger one (bottom) disk to destination peg
And finally, we move the smaller one from aux to destination peg.
So steps to follow are −
Step 1 − Move n-1 disks from source to aux
Step 2 − Move nth disk from source to dest
Step 3 − Move n-1 disks from aux to dest
Therefore, the recursive algorithm should be:
START
Procedure Hanoi(disk, source, dest, aux)
IF disk == 0, THEN
 move disk from source to dest 
 ELSE
 Hanoi(disk - 1, source, aux, dest) // Step 1
 move disk from source to dest // Step 2
 Hanoi(disk - 1, aux, dest, source) // Step 3
 END IF
END Procedure
STOP
