![]() ![]() A key to solving this puzzle is recognizing that we can solve it by breaking the problem down into a collection of smaller problems and further breaking those problems down into even smaller problems until a solution is reached. No one seems to have noticed before that while this algorithm does indeed accomplish the specied task, it does not do so in the minimum number of moves. We can easily solve the Tower of Hanoi problem using recursion. The solution to this relation is easily seen to be N(n) 3n1. Following are the steps that were taken by the proposed solution: The state can be represented by four stacks, S1S4, representing the pegs num- bered left to right. One example: Each disk is represented by Di, where Diis smaller than Djfor all i < j. 1.1 (3 points) De ne a state representation. The minimum number of moves required to solve a Tower of Hanoi puzzle is 2 n-1, where n is the total number of disks.Īn animated solution of the Tower of Hanoi puzzle for n = 4 can be seen here. Figure 1: Four-peg version of the Tower of Hanoi. ![]() No disk may be placed on top of a smaller disk.Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack, i.e., a disk can only be moved if it is the uppermost disk on a stack.The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules: The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, making a conical shape. Differing from the previous studies on demonstration Hanoi Tower algorithm based on desktop implementation, this paper adopts cross-platform HTML5 technology. The Tower of Hanoi is a mathematical puzzle consisting of three rods and n disks of different sizes which can slide onto any rod.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |