Write a procedure to produce the alternative description

Assignment Help Data Structure & Algorithms
Reference no: EM13912767

The solution to the Towers of Hanoi problem given in the text assumes that the pegs are numbered, and the complete description is in those terms. Thus 1 3 is interpreted as move the (top) ring from peg 1 to (become the top ring of) peg 3. An alternative view is to assume that the n·ngs are numbered from the smallest to the largest starting at 1. We can then describe moves by indicating the ring to be moved and its direction. For convenience we will describe the directions as clockwise (C), and anticlockwise (A ), thinking of the towers as being in a triangular formation with the pegs numbered anticlockwise. Thus the following are two alternative descrip­ tions of moving a tower for n=3.

13 IC
12 2A
32 IC
13 3C
21 IC
23 2A
1 3 IC

Write a procedure to produce the alternative description of the moves based on the observations:

(i) If we can move a tower of k rings in either direction we can certainly move a tower of k +1rings by:

(a) moving the top k rings in the opposite direction ;

(b) moving ring k +1 in the correct direction ;

(c) moving the top k rings again in the opposite direction.

(ii) We can trivially move one ring.

Reference no: EM13912767

Questions Cloud

Designing a mobile computing application : As using the GPS is battery consuming, the app should also be sensitive to battery levels and perhaps stop GPS based tracking or disallow tracking or warn the user if battery levels are too low - When a tracked path is saved, LTUPersonalLogger shou..
Force needed to drive the conveyor : Sand drops at the rate of 2000 kg/min. from the bottom of a hopper onto a belt conveyor moving horizontally at 250 m/min. Determine the force needed to drive the conveyor, neglecting friction.
A standard cost approach : A fast-food restaurant uses a standard cost approach to aid in controlling its food cost. The following are the standard cost, sales prices, and quantities sold of each of the five items featured on the menu during a particular week:
Money in the economy changed : While Jon is walking to school one morning, a helicopter flying overhead drops a $100 bill. Not knowing how to return it, Jon keeps the money and deposits it in his bank.After this initial transaction, by how much is the money in the economy changed.
Write a procedure to produce the alternative description : Write a procedure to produce the alternative description of the moves based on the observations If we can move a tower of k rings in either direction we can certainly move a tower of k +1rings.
Calculate the acceleration of the system : The block m1=1 kg sliding on a flat frictionless surface is connected by a string over a pulley to the hanging block m2=10kg. The system is released from the rest. Calculate the acceleration of the system
Statement of cash flows : Which one of the following categories on a statement of cash flows is used to report the cash flow effects of buying and selling property, plant, and equipment
Kinetic energy as the cricket ball : A cricket bowler can bowl a 158 g ball at 147 km/hr. Calculate the kinetic energy of this bowl and use this to compare to a bowling ball that weighs 7 kg. How fast would the bowling ball need to be bowled to have the same kinetic energy as the cri..
Bank reconciliation : A restaurant carries out a monthly bank reconciliation. The August 31 reconciliation showed the following: The restaurant bank balance is $4,112 and the bank statement balance is $2,760. Prepare a bank reconciliation for August 2004.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Comparison of the applicability of array

Data structures include: 1. a linked list, 2. an ordered, one dimensional array, and three. a binary tree. Assume the list of letters R, A, N, B, C, F, X and G are stored in a list.

  Determine expected number of collisions use hash function

Assume we use hash function h to hash n distinct keys into the array T of length m. Suppose simple uniform hashing, determine the expected number of collisions?

  Compare and contrast link-state and distance-vector routing

Examine the corresponding ping reply packet. What are the ICMP type and code numbers? What other fields does this ICMP packet have?

  Design and develop a database

The following assignment is based on the database environment chosen and created in the Week Three Individual Assignment.

  Creating an exception class and applet file

Create an applet document that prompts the user for an ID number and an age. Construct an Exception class and throw an Exception of that class if the ID is not in the range of valid ID numbers.

  Write a program that uses the bubble sort algorithm

You need to write a program that uses the bubble sort algorithm and load data into an array and then sort it into ascending order. It should output the first five and last five numbers from the file both before and after the sort.

  Describe the requirement for complex data structures

Describe the requirement for complex data structures and how they are utilized. Describe the design and application of arrays and how the array simplifies program development.

  Process a weighted undirected graph

Set up and print the adjacency matrix representation of the Graph.

  Question about indexed strategy

Think about a file system on a disk that has both logical and physical block sizes of 512 bytes. Suppose that the data about each file is already in memory.

  Algorithm to take input m constraints over n variables

For instance, the constraints x1 = x2, x2 = x3, x3 = x4, and x1 6= x4 cannot be satis fied. Give an efficient algorithm that takes as input m constraints over n variables and decides whether the constraints can be satis fied.

  Determine the objective of a query simplifier describe the

question 1 what is the objective of a query simplifier? what are the idempotence rules used by query simplifier? give

  Treat the problem as a directed graph with n nodes

Two distinct words can be joined if one, two or three of the letters at the end of the first word are the same as the letters at the beginning of the second word, and only if the letter/letters are in the same order.

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