Your SlideShare is downloading.
×

×

Saving this for later?
Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.

Text the download link to your phone

Standard text messaging rates apply

Like this presentation? Why not share!

- towers of hanoi by student 147 views
- Tower of hanoi by Elijah Hanson 1351 views
- Tower of hanoi by Iffat Anjum 220 views
- Dc8c4f010f40.hanoi.towers by Sumedha 1057 views
- Heap sort by Mohd Arif 1911 views
- Towers Hanoi Algorithm by Jorge Jasso 464 views
- Tower of hanoi problem by Tyler Murphy 81 views
- CPP12 - Algorithms by Michael Heron 56 views
- Tower of Hanoi using AI technique -... by Shubham Nimiwal 131 views
- Problem space by harman_sekhon 961 views
- First aid andriod in defence by Rehan Ahmed 1155 views
- Savitch Ch 14 by Terry Yoast 1700 views

516

Published on

Tower of Hanoi

Tower of Hanoi

No Downloads

Total Views

516

On Slideshare

0

From Embeds

0

Number of Embeds

1

Shares

0

Downloads

23

Comments

0

Likes

1

No embeds

No notes for slide

- 1. Created By ANKIT S. CHITNAVIS
- 2. Tower of Hanoi is a mathematical game or puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape. The objective of the puzzle is to move the entire stack to another rod, obeying the following rules: 1.Only one disk must be moved at a time. 2.Each move consists of taking the upper disk from one of the rods and sliding it onto another rod, on top of the other disks that may already be present on that rod. 3.No disk may be placed on top of a smaller disk.
- 3. The puzzle can be played with any number of disks. The minimum number of moves required to solve a Tower of Hanoi puzzle is 2n - 1 where n is the number of disks. Solution for Tower of Hanoi :For an even number of disks: make the legal move between pegs A and B make the legal move between pegs A and C make the legal move between pegs B and C repeat until complete For an odd number of disks: make the legal move between pegs A and C make the legal move between pegs A and B make the legal move between pegs C and B repeat until complete. In each case, a total of 2ⁿ-1 moves are made.
- 4. Algorithm Input :- Input of discs in Tower of Hanoi , specification of ORG as from the piller and DES as to piller,INT as the intemediate piller. Output :- Steps of moves of N discs from piller ORG to DCS piller. Steps 1. if N>0 then 2. move(N-1 ,ORG ,DES ,INT) 3. ORG DES (move from ORG to DES) 4. move(N-1 ,INT ,ORG ,DES) 5. end if 6. stop
- 5. For N=3 , how will this recursion solve the problem as shown Move(2,A,C,B) A B Move(1,C,A,B) Move(3,A,B,C) A C Move(1,B,C,A) Move(2,B,A,C) B C MoveE(1,A,B,C) C ( 1) A B (2) C B (3) A Move(1,A,B,C) A C (4) B A (5) B C (6) A C (7)
- 6. Example :- For 3 disk Move= - 1= 7
- 7. Thank You

Be the first to comment