16
Aumm-e-hani munir Maria umer Rakhshanda batool Faiza

P resentation

  • Upload
    chelsey

  • View
    61

  • Download
    0

Embed Size (px)

DESCRIPTION

P resentation. Aumm-e-hani munir Maria umer Rakhshanda batool Faiza. Tower of honii. What is Tower of hanoii. - PowerPoint PPT Presentation

Citation preview

Page 1: P resentation

Aumm-e-hani munirMaria umer

Rakhshanda batoolFaiza

Page 2: P resentation
Page 3: P resentation

DEFINATION:The Tower of Hanoi is one of the truly classic puzzle games. In the Tower of Hanoi puzzle a player attempts to move a large pile of disks, known as the Tower, from the leftmost peg to the rightmost on the puzzle board.

RULES: The rules of the puzzle state that the player can only move one disk per turn and can never place a larger disk onto a smaller one at any time.

TYPE: Tower of Hanoi Puzzles may consist of any number of disks as long as they total three or more.

Page 4: P resentation

Lets start with three disk

Page 5: P resentation
Page 6: P resentation
Page 7: P resentation
Page 8: P resentation
Page 9: P resentation
Page 10: P resentation
Page 11: P resentation
Page 12: P resentation

FUNCTION MoveTower(disk, source, dest, spare): IF disk == 0, THEN: move disk from source to dest ELSE: MoveTower(disk - 1, source, spare, dest) // Step1 above

move disk from source to dest // Step 2 above

MoveTower(disk - 1, spare, dest, source) // Step 3 above

END IF

Page 13: P resentation

Another way to visualize what happens when you run MoveTower is called a call tree. This is a graphic representation of all the calls. Here is a call tree for MoveTower(3,A,B,C).

Page 14: P resentation
Page 15: P resentation

we will consider the state at the top of the figure the starting state.

In this case all three disks are on the left-most peg. And we will consider the state at the bottom right to be the goal state.

Three disks are now all stacked on the right-most peg.

Page 16: P resentation

Thanks for your patienceHave a nice day……..