Solve the problem of towers of hanoi

Assignment Help Basic Computer Science
Reference no: EM131609299

Question: Towers of Hanoi. There is a story about Buddhist monks who are playing this puzzle with 64 stone disks. The story claims that when the monks finish moving the disks from one post to a second via the third post, time will end.

A stack of n disks of decreasing size (from bottom to top) is placed on one of three posts. The task is to move the disks one at a time from the first post to the second. To do this, any disk can be moved from any post to any other post, subject to the rule that you can never place a larger disk over a smaller disk. The (spare) third post is provided to make the solution possible. Your task is to write a recursive static method that gives instructions for a solution to this problem. We do not want to bother with graphics, so you should output a sequence of instructions that will solve the problem. The number of disks is a parameter to the method. Hint: If you could move up n-1 of the disks from the first post to the third post using the second post as a spare, the last disk could be moved from the first post to the second post. Then, by using the same technique (whatever that may be), you can move the n-1 disks from the third post to the second post, using the first disk as a spare. There! You have the puzzle solved. You have only to decide what the nonrecursive case is, what the recursive case is, and when to output instructions to move the disks.

Reference no: EM131609299

Questions Cloud

How much money was invested in the cd? account : The total interest earned after one year is ?$480.00. ?How much money was invested in the CD? account?
What financial reports : What financial reports are included in the annual report? What are the major types of information contained in each of these reports?
What is the importance of change management : What is the importance of Change Management? How will you effectively manage the change in your organization? What kind of hurdles will you encounter?
Firm weighted average cost of capital : Determine the firm's weighted average cost of capital (WACC). Calculate the traditional net present value (NPV) of the project using the WACC.
Solve the problem of towers of hanoi : A stack of n disks of decreasing size (from bottom to top) is placed on one of three posts. The task is to move the disks one at a time from the first post.
The use of health information technology : Discuss how the use of health information(HI) technology has influenced your current nursing practice.Give Examples.
Explain criminal justice organizations : Elaborate on the predictions of some of our major futurists and the impact their predictions might have for our society and for criminal justice organizations
Summarize the nature of the program : Identify what need the program was intended to affect. Discuss how the program was funded, including the funding organization
What is the quick sort algorithm : Which of the following would give the fastest run time when an array is sorted using the quick sort algorithm: a fully sorted array, an array of random values.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Better software tool internet explorer or mozilla firefox

There are several Internet browsers available today, and many people select which to use without giving it consideration. Explain which is better software tool: Internet Explorer, Mozilla Firefox, or Google Chrome?

  What state does the counter go on the next clock pulse

A 4-bit ripple counter consists of flip-flops, which each have a propagation delay from clock to Q output of 15 ns. For the counter to recycle from 1111 to 0000, it takes a total of ________.

  Define mitigation techniques

Perform a high level risk analysis for this project. Be sure to define mitigation techniques.

  Formulate and prove an analogous result for upper bounds

Show that the optimal modelfree lower bound for D is always less than or equal to f (So). Formulate and prove an analogous result for upper bounds.

  Determine the reduced state diagram

(State Reduction) Given the state diagram in Figure Ex. 8.4, deter-mine which states should be combined to determine the reduced state diagram. You may use row-matching or implication charts.

  Design a class named textbook

Design a class named TextBook that is a child class of Book. Include a new data field for the grade level of the book.

  Develop a new web-based system

Tom, Jan, and Julie are IS majors at Great State University. These students have been assigned to a class project by one of their professors, requiring them to develop a new Web-based system to collect and update information on the IS program's al..

  List the number (count) of unreserved room

List the guests by guest number, last name, first name and the number of times each guest has stayed in one of our hotels (include all reservations, past, current and future). Arrange the list in order from most-frequent stayer (greatest number of st..

  Write a paragraph describing at least two reasons

The IPv6 Network Addressing Standard was published back in 1998. Write a paragraph describing at least two reasons why the conversion to IPv6 has not been completed.

  Perform a postmortem on one of your own projects

Perform a postmortem on one of your own projects. What would you have done differently were you to do the project again? How do you know that these lessons will improve the next project you do?

  Implement in the presentation

You talk with Mike and Tiffany at lunch. "You've done some great research and brought up some good ideas to implement in the presentation,"

  Can snmp reference the entire row of a table

Can SNMP reference the entire row of a table? In other words, can SNMP retrieve or change the values in the entire row of a table? Explain.

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