Question

Describe an algorithm to solve the variant of the Towers of Hanoi in as few moves...

Describe an algorithm to solve the variant of the Towers of Hanoi in as few moves as possible. Prove that your algorithm is correct. Initially, all the n disks are on peg 1, and you need to move the disks to peg 2. You are not allowed to put a bigger disk on top of a smaller disk.

1. Suppose you are only allowed to move disks from peg 0 to peg 1, from peg 1 to peg 2, or from peg 2 to peg 0. Provide an upper bound, as tight as possible, on the nubmer of moves that your algorithm uses.

Homework Answers

Answer #1

The Towers of Hanoi problem can be solved recursively as follows. Let Tn be the minimum number of steps needed to move an n-disk tower from one post to another. For example, a bit of experimentation shows that T1 = 1 and T2 = 3. For 3 disks, the solution given above proves that T3 ≤ 7. We can generalize the approach used for 3 disks to the following recursive algorithm for n disks. Step 1. Move the top n − 1 disks from the first post to the third post. This can be done in Tn−1 steps. 1

  | 1 |   | | | | | 1 |

| 2 . | | | | | | . |

| . | | | | | | 2 |

| n | | | ⇒ | n | | n-1 |

Step 2. Move the largest disk from the first post to the to the second post. This requires just 1 step. 1 2 . . . n n−1 ⇒ 1 2 . . . n n−1

|      |   | 1 | |    | 1 | |

|    | | 2 | | | . | |

| . | | | | | 2 | |

| n| | n-1 | ⇒     | n   | n-1 | |

Step 3. Move the n − 1 disks from the third post onto the second post. Again, Tn−1 steps are required. 1 2 . . . n n−1 ⇒ 1 2 . . . n

|      |   | 1 | | | | 1 |

|    | | 2 | | | | 2 |

| . | | | | | | . |

| | n | n-1 | ⇒ |     | | n |

This calculation shows that Tn, the quantity of steps needed to move n plates to an alternate post, is all things considered 2Tn−1 + 1. We can utilize this reality to register upper limits on the quantity of steps required for different quantities of circles:

T3 ≤ 2 · T2 + 1 = 7 T4 ≤ 2 · T3 + 1 ≤ 15

it shows that the quantity of steps required is in any event 2Tn−1 + 1. Since we gave a calculation utilizing precisely that number of steps, we presently have a repeat for Tn, the quantity of moves needed to finish the Tower of Hanoi issue with n plates: T1 = 1 Tn = 2Tn−1 + 1 (for n ≥ 2) We can utilize this repeat to presume that T2 = 3, T3 = 7, T4 = 15, . . ..

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I have a recursive Tower of Hanoi program but don't know how to include the count...
I have a recursive Tower of Hanoi program but don't know how to include the count variable. Could you tell me how? Main.java import java.io.*; import java.util.List; public class Main { //int count = 0; /**There is a stack of N disks on the first of three poles (call them A, B and C) and your job is to move the disks from pole A to pole B without ever putting a larger disk on top of a smaller disk.*/...
Take screenshots of functions running in cLISP. Provide a description for each screenshot. 1. Create the...
Take screenshots of functions running in cLISP. Provide a description for each screenshot. 1. Create the function DecTree that will implement decision tree. Your function should accept input of decimal string (list) of repeated entries. Apply binary decision tree to find repetitions of each decimal digit in the string.     2. Let’s have n disks of graduated sizes: D1, D2, D3,… Dn 3. In addition, let’s have a 3 pegs, on which those disk could be stacked on: 1, 2,...
## We will be simulating the ideal solution to Hanoi's tower problem. ## The discs will...
## We will be simulating the ideal solution to Hanoi's tower problem. ## The discs will be numers from 0 to n-1, with the larger number being the smaller disc. ## each rod with discs will be encoded by a list, from bottom to top. For example, a rod with discs 0, 3, 5 will be encoded as [0,3,5] ## current configuration of rods will be encoded as a list of 3 lists. For example, starting state with 3 discs...
The following algorithm finds the initial substring of y that can be reversed and found in...
The following algorithm finds the initial substring of y that can be reversed and found in y. For example, longestInitialReverseSubstringLength(“aabaa”) = 5, because “aabaa” is the same string forwards and backwards, so the longest initial substring that can be reversed and found in the string is “aabaa”. Also, longestInitialReverseSubstringLength(“bbbbababbabbbbb”) is 6, because “babbbb” can be found in the string (see color-highlighted portions of the string), but no longer initial string exists reversed in any part of the string. longestInitialReverseSubstringLength(String y)...
Create in JAVA Suppose you are designing a game called King of the Stacks. The rules...
Create in JAVA Suppose you are designing a game called King of the Stacks. The rules of the game are as follows:  The game is played with two (2) players.  There are three (3) different Stacks in the game.  Each turn, a player pushes a disk on top of exactly one of the three Stacks. Players alternate turns throughout the game. Each disk will include some marker to denote to whom it belongs.  At the end...
Use a few sentences to describe the problem given below . Also, Identify the nouns and...
Use a few sentences to describe the problem given below . Also, Identify the nouns and verbs used in the below project descriptions.  Identified nouns, list the ones that are necessary to define variables in your program. For each variable, specify its name, data type, and what information it is used to store. Write the pseudo code algorithm (i.e. algorithm steps) to solve this problem. (For the base salaries and commission rates use constants instead to keep these values. Use the...
There are N blocks, numbered from 0 to N-1, arranged in a row. A couple of...
There are N blocks, numbered from 0 to N-1, arranged in a row. A couple of frogs were sitting together on one block when they had a terrible quarrel. Now they want to jump away from one another so that the distance between them will be as large as possible. The distance between blocks numbered J and K, where JK, is computed as K-J+1. The frogs can only jump up, meaning that they can move from one block to another...
1. Use a tree diagram to show, or list, all possible outcomes when you toss a...
1. Use a tree diagram to show, or list, all possible outcomes when you toss a coin 3 times. 2. Licence plates consist of either 3 letters and 3 numbers or 4 letters and 3 numbers. How many different licence plates can be issued? 3a)      In how many ways can a committee of three be selected from 12 students? b) In how many ways can a president, secretary, and treasurer be chosen from 12 students? 4. How many ways...
IN JAVA Speed Control Problem: The files SpeedControl.java and SpeedControlPanel.java contain a program (and its associated...
IN JAVA Speed Control Problem: The files SpeedControl.java and SpeedControlPanel.java contain a program (and its associated panel) with a circle that moves on the panel and rebounds from the edges. (NOTE: the program is derived from Listing 8.15 and 8.16 in the text. That program uses an image rather than a circle. You may have used it in an earlier lab on animation.) The Circle class is in the file Circle.java. Save the program to your directory and run it...
Homework Draw class diagrams for your HW4 - the Tetris Game shown below: Part 1: UML...
Homework Draw class diagrams for your HW4 - the Tetris Game shown below: Part 1: UML As a review, Here are some links to some explanations of UML diagrams if you need them. • https://courses.cs.washington.edu/courses/cse403/11sp/lectures/lecture08-uml1.pdf (Links to an external site.) • http://creately.com/blog/diagrams/class-diagram-relationships/ (Links to an external site.) • http://www.cs.bsu.edu/homepages/pvg/misc/uml/ (Links to an external site.) However you ended up creating the UML from HW4, your class diagram probably had some or all of these features: • Class variables: names, types, and...