Tower of hanoi

76
TOWER OF HANOI

description

Tower of hanoi. Pseudo code. 1. Start 2. It has 3 bars and 5 rings 3. Which bar will we move ring number1 to? 4. Bar C 5. Ring 1 in bar C 6. Which bar will we move ring number2 to? 7. Bar B 8. Ring 2 in bar B - PowerPoint PPT Presentation

Transcript of Tower of hanoi

Page 1: Tower  of   hanoi

TOWER OF HANOI

Page 2: Tower  of   hanoi
Page 3: Tower  of   hanoi
Page 4: Tower  of   hanoi
Page 5: Tower  of   hanoi

1. Start 2. It has 3 bars and 5 rings 3. Which bar will we move ring number1 to? 4. Bar C 5. Ring 1 in bar C 6. Which bar will we move ring number2 to? 7. Bar B 8. Ring 2 in bar B 9. Which bar will we move ring number1 to? 10. Bar B 11. Ring 1 in bar B 12. Which bar will we move ring number3 to?

Pseudo code

Page 6: Tower  of   hanoi

10. Bar C 11. Ring 3 in bar C 12. Which bar will we move ring number1 to? 13. Bar A 14. Ring 1 in bar A 15. Which bar will we move ring number2 to? 16. Bar C 17. Ring 2 in bar C 18. Which bar will we move ring number1 to? 19. Bar C 20. Ring 1 in bar C 21. Which bar will we move ring number4 to? 22. Bar B 23. Ring 4 in bar B 24. Which bar will we move ring number1 to? 25. Bar B

Page 7: Tower  of   hanoi

26. Ring 1 in bar B 27. Which bar will we move ring number2 to? 28. Bar A 29. Ring 2 in bar A 30. Which bar will we move ring number1 to? 31. Bar A 32. Ring 1 in bar A 33. Which bar will we move ring number3 to? 34. Bar B 35. Ring 3 in bar B 36. Which bar will we move ring number1 to? 37. Bar C 38. Ring 1 in bar C 39. Which bar will we move ring number2 to? 40. Bar B 41. Ring 2 in bar B

Page 8: Tower  of   hanoi

42. Which bar will we move ring number1 to? 43. Bar B 44. Ring 2 in bar A 45. Which bar will we move ring number5 to? 46. Bar C 47. Ring 5 in bar C 48. Which bar will we move ring number1 to? 49. Bar A 50. Ring 1 in bar A 51. Which bar will we move ring number2 to? 52. Bar C 53. Ring 2 in bar C 54. Which bar will we move ring number1 to? 55. Bar C 56. Ring 1 in bar C 57. Which bar will we move ring number3 to ? 58. Bar A

Page 9: Tower  of   hanoi

59. Ring 3 in bar A 60. Which bar will we move ring number1 to? 61. Bar B 62. Ring 1 in bar B 63. Which bar will we move ring number2 to? 64. Bar A 65. Ring 2 in bar A 66. Which bar will we move ring number1 to? 67. Bar A 68. Ring 1 in bar A 69. Which bar will we move ring number4 to? 70. Bar C 71. Ring 4 in bar C 72. Which bar will we move ring number1 to? 73. Bar C 74. Ring 1 in bar C 75. Which bar will we move ring number2 to?

Page 10: Tower  of   hanoi

76. Bar B 77. Ring 2 in bar B 78. Which bar will we move ring number1 to? 79. Bar B 80. Ring 1 in bar B 81. Which bar will we move ring number3 to 82. Bar C 83. Ring 3 in bar C 84.. Which bar will we move ring number1 to? 85. Bar A 86. Ring 1 in bar A 87. Which bar will we move ring number2 to? 89. Bar C 90. Ring 2 in bar C 91. Which bar will we move ring number1 to? 92. Bar C

Page 11: Tower  of   hanoi

93. Ring 1 in bar C 94. Win 95. End

********************************

Page 12: Tower  of   hanoi

Flow Chart

Page 13: Tower  of   hanoi

start

5 rings and

3bars

Which bar will we

move ring 1 to?

Bar B Bar C

Ring 1 in bar C

No

Yes

Page 14: Tower  of   hanoi

Which bar will we

move ring 2 to?

Bar B Bar C

Ring 2 in bar B

No Yes

Page 15: Tower  of   hanoi

Which bar will we

move ring 1 to?

Bar A Bar B

Ring 1 in bar B

No Yes

Page 16: Tower  of   hanoi

Which bar will we

move ring 3 to?

Bar B Bar C

Ring 3 in bar C

No Yes

Page 17: Tower  of   hanoi

Which bar will we

move ring 1 to?

Bar A Bar C

Ring 1 in bar A

Yes No

Page 18: Tower  of   hanoi

Which bar will we

move ring 2 to?

Bar A Bar C

Ring 2 in bar C

YesNo

Page 19: Tower  of   hanoi

Which bar will we

move ring 1 to?

Bar B Bar C

Ring 1 in bar C

YesNo

Page 20: Tower  of   hanoi

Which bar will we

move ring 4 to?

Bar B Bar C

Ring 4 in bar B

Yes No

Page 21: Tower  of   hanoi

Which bar will we

move ring 1 to?

Bar A Bar B

Ring 1 in bar B

YesNo

Page 22: Tower  of   hanoi

Which bar will we

move ring 2 to?

Bar A Bar B

Ring 2 in bar A

Yes No

Page 23: Tower  of   hanoi

Which bar will we

move ring 1 to?

Bar A Bar C

Ring 1 in bar A

Yes No

Page 24: Tower  of   hanoi

Which bar will we

move ring 3 to?

Bar A Bar B

Ring 3 in bar B

YesNo

Page 25: Tower  of   hanoi

Which bar will we

move ring 1 to?

Bar B Bar C

Ring 1 in bar C

YesNo

Page 26: Tower  of   hanoi

Which bar will we

move ring 2 to?

Bar B Bar C

Ring 2 in bar B

Yes No

Page 27: Tower  of   hanoi

Which bar will we

move ring 1 to?

Bar A Bar B

Ring 1 in bar B

YesNo

Page 28: Tower  of   hanoi

Which bar will we

move ring 5 to?

Bar B Bar C

Ring 5 in bar C

YesNo

Page 29: Tower  of   hanoi

Which bar will we

move ring 1 to?

Bar A Bar C

Ring 1 in bar A

Yes No

Page 30: Tower  of   hanoi

Which bar will we

move ring 2 to?

Bar A Bar C

Ring 2 in bar C

YesNo

Page 31: Tower  of   hanoi

Which bar will we

move ring 1 to?

Bar B Bar C

Ring 1 in bar C

YesNo

Page 32: Tower  of   hanoi

Which bar will we

move ring 3 to?

Bar A Bar C

Ring 3 in bar A

Yes No

Page 33: Tower  of   hanoi

Which bar will we

move ring 1 to?

Bar A Bar B

Ring 1 in bar B

YesNo

Page 34: Tower  of   hanoi

Which bar will we

move ring 2 to?

Bar A Bar B

Ring 2 in bar A

Yes No

Page 35: Tower  of   hanoi

Which bar will we

move ring 1 to?

Bar A Bar C

Ring 1 in bar A

Yes No

Page 36: Tower  of   hanoi

Which bar will we

move ring 4 to?

Bar A Bar C

Ring 4 in bar C

YesNo

Page 37: Tower  of   hanoi

Which bar will we

move ring 1 to?

Bar B Bar C

Ring 1 in bar C

YesNo

Page 38: Tower  of   hanoi

Which bar will we

move ring 2 to?

Bar B Bar C

Ring 2 in bar B

Yes No

Page 39: Tower  of   hanoi

Which bar will we

move ring 1 to?

Bar A Bar B

Ring 1 in bar B

YesNo

Page 40: Tower  of   hanoi

Which bar will we

move ring 3 to?

Bar B Bar C

Ring 3 in bar C

YesNo

Page 41: Tower  of   hanoi

Which bar will we

move ring 1 to?

Bar A Bar C

Ring 1 in bar A

Yes No

Page 42: Tower  of   hanoi

Which bar will we

move ring 2 to?

Bar A Bar C

Ring 2 in bar C

YesNo

Page 43: Tower  of   hanoi

Which bar will we

move ring 1 to?

Bar B Bar C

No Yes

Ring 1 in bar C

Win

End

Page 44: Tower  of   hanoi
Page 45: Tower  of   hanoi
Page 46: Tower  of   hanoi
Page 47: Tower  of   hanoi
Page 48: Tower  of   hanoi
Page 49: Tower  of   hanoi
Page 50: Tower  of   hanoi
Page 51: Tower  of   hanoi
Page 52: Tower  of   hanoi
Page 53: Tower  of   hanoi
Page 54: Tower  of   hanoi
Page 55: Tower  of   hanoi
Page 56: Tower  of   hanoi
Page 57: Tower  of   hanoi
Page 58: Tower  of   hanoi
Page 59: Tower  of   hanoi
Page 60: Tower  of   hanoi
Page 61: Tower  of   hanoi
Page 62: Tower  of   hanoi
Page 63: Tower  of   hanoi
Page 64: Tower  of   hanoi
Page 65: Tower  of   hanoi
Page 66: Tower  of   hanoi
Page 67: Tower  of   hanoi
Page 68: Tower  of   hanoi
Page 69: Tower  of   hanoi
Page 70: Tower  of   hanoi
Page 71: Tower  of   hanoi
Page 72: Tower  of   hanoi
Page 73: Tower  of   hanoi
Page 74: Tower  of   hanoi
Page 75: Tower  of   hanoi
Page 76: Tower  of   hanoi