Towers of hanoi problem, Computer Engineering

Assignment Help:

The Towers of Hanoi Problem

Towers of Hanoi problem is described. There are three pegs on which disks are "threaded" (there are holes in the disks to allow them to be placed on the pegs). No two disks have the same size and one can never place a larger disk stop a smaller disk. Only one disk can be moved at a time (and when a disk is not being move, it must be on one of the pegs). The problems starts with all the disks on one peg and the goal is to move them all to one other peg.

Write a program that solves the Towers of Hanoi problem. However, we want to make some minor changes to the speci?cation provided in the textbook.

Instead of numbering the pegs 1, 2, and 3, number them 0, 1, and 2. You code should start with all the disk on peg 0 and the goal is to move them all to peg 2.

Call the function you write to solve the problem hanoi(). This is a void function. Instead of four parameters (as described in the textbook), the function should take ?ve parameters as follows:

1. The total number of disks on all the pegs.

2. The number of disks to be moved.

3. The peg on which the disks are initially threaded (i.e., the "source" peg).

4. The peg to which these disks are to be moved (i.e., the "destination" peg).

5. The peg to use as a temporary holding peg.

Note that parameters 2 through 5 in the list above are the same as the parameters 1 through 4 as described in the textbook. The only new parameter is the ?rst one and, once initially set, this parameter will not change throughout the remainder of the execution of the program  though not necessary for the solution of this problem, the reason for including this parameter will be more clear in the next problem.


Related Discussions:- Towers of hanoi problem

With what symbolic names can be associated, Symbolic names can be associate...

Symbolic names can be associated with? Ans. With data or instruction symbolic names associated.

Determine the equivalent hexadecimal form of decimal number, Solve the equa...

Solve the equation 65.535 10 = X 16 Ans. In order to get X, convert the Decimal number 65.535 in its equal Hexadecimal form. So first taking 65 the integer part to convert in i

Define the time required by sector to reach below read/write, is the time r...

is the time required by a sector to reach below read/write head. Latency Time is the time needed by a sector to reach below read/write head.

How can i delete a file, The Standard C Library function is removing. (This...

The Standard C Library function is removing. (This is thus one of the few questions in this section for which the answer is not ''It's system-dependent.'') On older, pre-ANSI Unix

Eme, state function and path function

state function and path function

What is the difference between thread and process, What is the difference b...

What is the difference between thread and process?  Thread - is used to execute more than one program at a time. process - executes single program A thread is a path of e

What is a symbolic constant, What is a symbolic constant? How it is defined...

What is a symbolic constant? How it is defined ? Symbolic constants are constants of any type declared by using the #define compiler directive. It is a preprocessor directive.

Draw the logic diagram of 4-bit twisted ring counters, Draw the logic diagr...

Draw the logic diagram of 4-bit Twisted Ring counters and explain its operation with the help of timing diagram. Ans: Twisted ring counter (4 BIT): We ready know that shi

Recordable cds and dvds, Optical disk becomes an attractive alternative for...

Optical disk becomes an attractive alternative for backing up information from hard disk drives and employs large text, audio and video data. Advent of CD-ROM-R and DVD-ROM-R has b

Explain the benefits of interpreter, Explain the Benefits of Interpreter? ...

Explain the Benefits of Interpreter? The benefit of an interpreter though is that it doesn't need to go through the compilation stage during which machine instructions are gene

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd