Explain the Tower of Hanoi (TOH) with practical example.

This answer is restricted. Please login to view the answer of this question.

Login Now

Tower of Hanoi (TOH) is a mathematical puzzle which consists of three pegs named as origin, intermediate and destination and more than one disks. These disks are of different sizes and the smaller one sits over the larger one.

In this problem we transfer all disks from origin peg to destination peg using intermediate peg for temporary storage and move only one disk at a time.

The tower of Hanoi puzzle problem

 

Algorithm for TOH problem:

To move a tower of n disks from source to destination

  1. If n == 1:
    1. Move a single disk from source to destination
  2. If n > 1:
    1. Let temp be the remaining pole other than source and destination
    2. Move a tower of (n-1) disks from source to temp
    3. Move a single disk from source to destination
    4. Move a tower of (n-1) disks from temp to destination
  3. Stop

Example for 3 disks: 7 moves

User Loaded Image | CSIT Guide

If you found any type of error on the answer then please mention on the comment or report an answer or submit your new answer.
Leave your Answer:

Click here to submit your answer.

Discussion
0 Comments
  Loading . . .