6
$\begingroup$

I'm having trouble understanding precisely how the proof by induction is used to show that it takes at most $2^n-1$ moves to get all the disks from one peg to another. Are there any helpful sources or particular insight that you have that may help me, and others, understand this problem more intuitively?

$\endgroup$

4 Answers 4

4
$\begingroup$

Here's a proof. Basically, the idea behind the induction is this: To solve the case with $n$ disks, you first have to get the top $n-1$ of the disks onto one peg so that you can move the bottom disk. By inductive hypothesis, this takes $2^{n-1}-1$ moves. Then it takes one move to get the bottom disk where it needs to go. Then you have to solve the $n-1$ disk case again, to get them on top of the bottom disk, which takes another $2^{n-1}-1$ moves. So the total number of moves is $$[2^{n-1}-1] + 1 + [2^{n-1}-1] = 2^n - 1.$$

$\endgroup$
2
$\begingroup$

The proof goes as follows: for one disk, it takes $1=2^1-1$ move. Assume for up to $n$ disks it takes $2^n-1$ moves. Then for $n+1$ disks, you first have to move the top $n$ to an empty peg, taking $2^n-1$ moves. Next, you move disk $n+1$ to the other empty peg, taking $1$ move. Third, you move the tower of $n$ disks from where it is onto disk $n+1$, again taking $2^n-1$ moves. The total number of moves is $(2^n-1)+1+(2^n-1)=2^{n+1}-1$

$\endgroup$
1
$\begingroup$

I have a large pile of disks on peg A, no disks on peg B, and no disks on peg C.

My aim is to construct an algorithm to move n disks from one peg to another. If only I had an algorithm to move n-1 disks from one peg to another - after all, then I could construct an algorithm for n in three simple steps:

  1. move the top n-1 disks from A to B
  2. move the bottom disk from A to C
  3. move the n-1 disks from B to C.

That is, if I have an algorithm that works for n-1, I can very easily construct one (in the three steps I just outlined) that works for n.

But wait - I can move one disk. So let's set n = 2. I have an algorithm that works for 1, so I get one that works for 2. Oh, and now I can set n = 3...

$\endgroup$
0
$\begingroup$

[Taken from lecture 6 here]

The (inductive) instructions are:

enter image description here

Here is python code and an example run for 4 disks:

enter image description here


If interest is to count the number of individual steps ${ T _n ,}$ we see ${ T _n = T _{n-1} + 1 + T _{n-1}, }$ that is ${ T _n = 2 T _{n-1} + 1 }$ (with ${ T _1 = 1 }$). As shown in the above answers, ${ T _n = 2 ^{n} - 1 }.$

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .