Question
Suppose we have M pegs $(p_1,p_2,\cdots,p_M)$ and all N disks are on $p_1$. We need to move them to $p_M$ under the Lucas rule. How many moves are required at least?
Basic solution
The Frame-Stewart Algorithm’s pipeline is as followed:
- Move $T$ disks from $p_i$ to $p_j$, where $j\neq M$
- Move $N-T$ disks from $p_i$ to $p_M$
- Move $T$ disks from $p_j$ to $p_M$
This algorithm divides the solution into three stages, which actually divides the Hanoi tower into a main-tower(the lower $N-T$ disks) and a sub-tower(the upper $T$ disks).
For example, the Hanoi tower with 3 disks can be divided into a main-tower in the first peg with only one disk, the sub-tower is in the third peg with two disks. In this way, a Hanoi problem with more disks can be transferred into a solved Hanoi problem with less disks(the sub-tower’s move is a solved problem). When there are more than three pegs, the Hanoi tower can be divided into many sub-towers recursively. Finally, we can get the recursive formula: $Hanoi[M][N]:=\min_{1\leq r<N}(2Hanoi[M][r]+Hanoi[M-1][N-r])$, the initial condition is $Hanoi[3][n]=2^n-1,\ \ Hanoi[n][1]=1$
The proof of the Frame-Stewart Algorithm used in four pegs can be found in A new lower bound for the Towers of Hanoi problem
Thinking of sub-minimum moves
We know the minimum amount of necessary moves to finish a Hanoi task of $Hanoi[3][n]$ is $2^n-1$. But what’s the sub-minimum moves of it?
We can consider it in the same way as the optimal method: Think back from the last step, we must move the sub-tower with upper n - 1 disks to the buffer peg then move the disk at bottom from the start peg to the target peg. Finally, we need to move the sub-tower with upper n - 1 disks to the target peg. The process indicates that the extra move compared with the optimal solution comes from the moving of the sub-tower, which means it’s also a recursive process.
However, there is a limitation that we can’t move the same disk continuously, which means we need to start from $Hanoi[3][2]$ (Define: $Hanoi[n][1]$ doesn’t have a sub-minimum solution). I enumerate all cases where the distribution of disks are the same to find the sub-optimal solution of $Hanoi[3][2]$ as followed.
The optimal solution:
The sub-optimal solution(two moves more than the optimal one):
Also, I have verified nine moves in $Hanoi[3][3]$ by hand, which is also two moves more than the optimal solution. It indicates that when there are three pegs, the sub-minimal solution might have two moves more than the optimal solution at the most. Then I get the formula: $subHanoi[3][n]=2^n+1,\ \ where \ \ n\geq2$.
Finally, I guess I can extend the result to the situation where has more pegs, the recursive formula of sub-minimum moves is
Furthermore, I calculate the exact number for $Hanoi[7][23]$ matrix and $subHanoi[7][23]$ with my computer, the source codes in C are in the appendix. The outputs are as followed:
M pegs | N disks | minimum moves | sub-minimum moves |
---|---|---|---|
5 | 13 | 55 | 57 |
7 | 13 | 39 | 41 |
5 | 19 | 103 | 105 |
7 | 19 | 63 | 65 |
5 | 23 | 159 | 161 |
7 | 23 | 87 | 89 |
Appendix: Source Code (C)
1 |
|