0% found this document useful (0 votes)
15 views4 pages

Explain Tower of Hanoi Problem by Moving 3 Discs

The document explains the Tower of Hanoi problem which involves moving disks of different sizes between three rods according to rules. It describes the objective is to move all disks from the initial rod to another rod and outlines the steps and algorithm to solve the problem for any number of disks.

Uploaded by

tilaksondagar411
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

Explain Tower of Hanoi Problem by Moving 3 Discs

The document explains the Tower of Hanoi problem which involves moving disks of different sizes between three rods according to rules. It describes the objective is to move all disks from the initial rod to another rod and outlines the steps and algorithm to solve the problem for any number of disks.

Uploaded by

tilaksondagar411
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Explain Tower of Hanoi problem by moving 3

discs.

What is the Tower of Hanoi problem?


The Tower of Hanoi, is a mathematical problem which consists of three rods
and multiple disks. Initially, all the disks are placed on one rod, one over the
other in ascending order of size similar to a cone-shaped tower.
The objective of this problem is to move the stack of disks from the initial rod
to another rod, following these rules:

 A disk cannot be placed on top of a smaller disk


 No disk can be placed on top of the smaller disk.

The goal is to move all the disks from the leftmost rod to the rightmost rod. To
move N disks from one rod to another, 2^𝑁−1 steps are required. So, to move
3 disks from starting the rod to the ending rod, a total of 7 steps are required.

Algorithm For Tower of Hanoi Puzzle


In Tower Of Hanoi puzzle we have three towers and some disks. We have to
move this disk from intial tower to destination tower using aux tower.
For an example lets take we have two disks and we want to move it from
source to destination tower.
So the approach we will follow
 First, we will move the top disk to aux tower.
 Then we will move the next disk (which is the bottom one in this case) to
the destination tower.
 And at last, we will move the disk from aux tower to the destination
tower.
Similarly if we will have n number of disk then our aim is to move bottom
which is disk n from source to destination. And then put all other (n-1) disks
onto it.
Steps we will follow is
 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
Means to move n > 1 disks from tower 1 to tower 2, using auxiliary tower 3
 Step 1- Move n – 1 disks from Tower 1 to tower 3
 Step 2 – Move the n-th disk from Tower 1 to Tower 2
 Step 3 – Move n – 1 disk from Tower 3 to Tower 2

Pictorial Representation of How Tower of Hanoi works


Let’s see the below example where we have three disks that have to move in
the destination tower which is the middle one with the help of the auxiliary
tower.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy