Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Reve's puzale. Reve's puzzle is identical to the towers of Hanoi problem, except that there are 4 poles (instead of 3 ). The task

image text in transcribed
3. Reve's puzale. Reve's puzzle is identical to the towers of Hanoi problem, except that there are 4 poles (instead of 3 ). The task is to move n dises of different sizes from the starting pole to the destination pole, while obeying the following rules: Move only one dise at a time. Never place a larger dise on a smaller one. The following remarkable algorithm, discovered by Frame and Stewart in 1941 , transfers n discs from the starting pole to the destination pole using the fewest moves (although this fact was not proven until 2014). Let k denote the integer nearest to n+12n+1 Transfer (recursively) the k smallest dises to a single pole other than the start or destination poles. Transfer the remaining nk disks to the destination pole (without using the pole that now contains the smallest k dises). To do so, use the algorithm for the 3-pole towers of Hanoi problem. Transfer (recursively) the k smallest discs to the destination pole. Write a program Revespuzzle. java that takes an integer command-line argument n and prints a solution to Reve's puzale. Assume that the the discs are labeled in increasing order of size from 1 to n and that the poles are labeled A,B, C, and D, with A representing the starting pole and D representing the destination pole. Here are a few sample executions: Note: you may assume that n is a positive integer. Recall that for the towers of Hanoi problem, the minimum number of moves for a 64-disc problem is 2641. With the addition of a fourth pole, the minimum number of moves for a 64 -dise problem is reduced to 18,433

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

When will I do them?

Answered: 1 week ago