Solved

solution to towers of hanoi

Posted on 2000-04-26
2
267 Views
Last Modified: 2010-05-18
i think i already know the answer but want to double check on my answer. the solution of the towers of hanoi with 7 disks requires how many disk moves? 128 disks
 
0
Comment
Question by:beachbumm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
imladris earned 10 total points
ID: 2753070
Now there's a recursive problem for ya!

Anyway, I'm coming to 127. I figure it as follows:

For a 1 disk problem: 1 disk move.

For a 2 disk problem:
    Move the smallest disk to an empty
    Move the bottom to another empty
    Move the smallest onto the other

    3 moves

For a 3 disk problem:

    Move the top two to an empty:3 moves
    Move the bottom to an empty
    Move the two onto the bottom:3 moves

    7 moves

So the number of moves for n disks looks like the number of moves for a stack one less times 2, plus one:

moves for stack of n=2*(moves for stack of n-1)+1

So we have:

1  -  1
2  -  3
3  -  7
4  -  15
5  -  31
6  -  63
7  - 127

That's almost the same you have. Are we defining the problem the same? Are we counting exactly the same thing? What do you think?
0
 

Author Comment

by:beachbumm
ID: 2753453
i was close..i forgot the equation of solution (2n -1)! thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question