Search code examples
towers-of-hanoi

Tower of Hanoi ordered numbers


Tower of Hanoi problem is how do I implement the following? please help me !

http://imageupload.co.uk/files/qpxsdyyxtbl5ik38zcn0.jpg


Solution

  • I dont know using which language you want to implement this. But you can implement this using stack.

    Suppose you have 3 pegs 1,2,3 and 3 disks A,B,C. You can implement it as follows:-

             A -> 3                  
             A -> 2
             C -> 2
             A -> 3
             B -> 1
             B -> 3
             A -> 3  
    

    You can refer to this link(http://www.mathcs.emory.edu/~cheung/Courses/170/Syllabus/13/hanoi.html) for more detailed solution.