Professional Documents
Culture Documents
Algorithms and Bounds For Tower of Hanoi Problems On Graphs
Algorithms and Bounds For Tower of Hanoi Problems On Graphs
Algorithms and Bounds For Tower of Hanoi Problems On Graphs
by
Rafi Cohen
The research work for this thesis has been carried out at
Ben-Gurion University of the Negev
under the supervision of Prof. Yefim Dinitz
May 2008
Subject: Algorithms and Bounds for Tower of Hanoi Prob-
lems on Graphs
This thesis is submitted as part of the requirements for the M.Sc. degree
Written by: Rafi Cohen
Advisor: Prof. Yefim Dinitz
Department: Computer Science
Faculty: Natural Sciences
Ben-Gurion University of the Negev
Table of Contents iv
List of Figures vi
Abstract vii
Acknowledgements ix
2 Preliminaries 20
2.1 Definition and Notations . . . . . . . . . . . . . . . . . . . . . 20
2.2 Block-Move Properties . . . . . . . . . . . . . . . . . . . . . . 25
2.3 Basic Results . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.4 Auxiliary Mathematical Results . . . . . . . . . . . . . . . . . 29
iv
3 Bounds for Maximal Almost-Acyclic Hanoi Graphs 34
3.1 Best Almost-Acyclic Hanoi Graph H`T C . . . . . . . . . . . . . 35
3.2 Algorithm for H`T C and Its Number of Steps . . . . . . . . . . 36
3.3 Lower Bound for a General Algorithm . . . . . . . . . . . . . 38
3.4 Measuring the Tightness of Our Bounds . . . . . . . . . . . . 41
3.5 Proofs of Theorems 3.2.1(2) and 3.3.1(2) . . . . . . . . . . . . 42
3.5.1 Proof of Theorem 3.2.1(2) . . . . . . . . . . . . . . . . 42
3.5.2 Proof of Theorem 3.3.1(2) . . . . . . . . . . . . . . . . 44
Bibliography 79
v
List of Figures
vi
Abstract
The classic Tower of Hanoi puzzle was marketed by Edouard Lucas in 1883
under the name ”Tower of Hanoi” [31]. There, n disks are due to be moved
from one peg to another, using an auxiliary peg while never placing a bigger
disk above a smaller one. Its optimal solution is classic in Computer Science.
In this thesis, we study a generalization of the original puzzle.
The problem is generalized by placing pegs on the nodes of a given di-
rected graph (Hanoi graph) H = (V (H), E(H)) with two distinguished nodes
S and D, and allowing moves only along edges of that path. An optimal solu-
tion for H is a shortest sequence of disk moves to transfer n disks from S to D;
we denote its length by time(H). Leiss [29] has shown that arbitrary many
disks can be moved from S to D if and only if there is a strongly-connected-
component (SCC) of size three or more in H, which can be reached from
S, and from which D can be reached. D. Azriel [5] studied Hanoi graphs,
with each SCC of size at most two, showing the number of disks that can be
1
moved from S to D in those graphs is at most h 2 log2 h , where h = |V (H)|.
Recently, Hanoi graphs consisting of (a SCC of size three, a path from S to
one of its nodes and an edge from S to that node) were studied, an algorithm
was suggested, and its optimality was proved [7].
We consider graphs which are composed of ` SCCs, each one isomorphic
to K3 , and concentrate on the logarithm of time(H), looking for asymptotic
vii
viii
First and foremost, I would like to thank my advisor, Prof. Yefim Dinitz.
During the thesis, I was always welcome, and each meeting with him con-
tributed a lot to the advance of the work. Many of the ideas grew out of our
conversations, and many improvements were based upon his insights. He is
an advisor in the full sense of the word.
I wish to thank Prof. Daniel Berend for his helpful suggestions.
I would also like to thank Shay Solomon, and Amir Sapir for all the help
and suggestions they provided.
I am especially grateful to Natali, for her unconditional love and support.
Lastly, I would like to thank my parents, for their affection, love and help,
throughout the years.
ix
Chapter 1
1.1 Origins
The original, well studied problem of the ”Towers of Hanoi” invented in 1883
by Lucas [31] can be stated as follows. There are three pegs, S, D, and A.
Peg S (source) contains n disks, no two of them of equal size, and upon any
given disk only smaller disk may rest. The problem is to find the shortest
(R1) Only one disk may be moved at a time; a move consists of transferring
the topmost disk from one peg to the top of all the disks on another
peg.
(R2) A disk may be moved from any peg to any other peg.
1
2
of the problem goes, is what really enables us solving it. In fact, for n ≥ 2
the problem would be unsolvable if we had only the source and destination
pegs.
a game it was built of a plate, three wooden sticks (the pegs) and several
expression. There, the number of disks was 64. As we shall see momentarily,
with this number of disks, the number of steps required for the solution is
over 1019 .
time analysis, which goes as follows. Let an denote the number of moves
required to perform the task with n disks. Clearly a1 = 1 and an = 2an−1 +1,
Even though the solution seems simple enough, there has been continuing
Section 1.2 and review work done previously in Section 1.3. Section 1.4
states the main questions studied in the current work and the main results.
dance with HR. A perfect configuration is one in which all disks are on the
same peg. A perfect task is the transfer of a tower of n disks from a perfect
For each n, we have a configuration graph H(n) , whose vertices are all con-
vertex itself, the number of pegs is h. The source initially contains n disks of
different sizes, such that smaller disks rest on top of larger ones. HR apply,
(R2’) A disk may be moved from a peg v to another peg w only if there is
The Tower of Hanoi problem HAN (H, n) for a Hanoi graph H and n ≥ 0
for all n ≥ 0.
may use the peg v, so that v may be omitted from the graph.
(Note that, in his formulation of the problem, V may contain inessential ver-
tices, and hence the formulation of the theorem hereby given is changed
5
accordingly.)
Theorem 1.2.1 [29] Let H = (V, E) be a Hanoi graph, and let H ∗ = (V, E ∗ )
be its transitive closure: E ∗ = {(v, w) : v 6= w, there is a path from v to w}.
Then H is solvable if and only if H ∗ contains a clique of size three.
Since the time of its inception, people have started developing versions of the
original puzzle, such as starting and ending with any configuration, adding
pegs, and imposing movement restrictions among the pegs, to mention just
a few. Here we will give a short description of some most known of them.
Stockmeyer [41].
Adding Pegs
One of the known early versions of this natural extension is the so-called
21 disks was presented (see Fig. 1.1), and one is required to move the tower
of disks from peg 1 to peg 4. The problem in its general form, that is any
chosen so that the overall number of moves will be minimal. It is well known
√
that, for 4 pegs, m should be approximately 2n. A variety of algorithms
have been proposed in the past few decades. Recently, [25] discussed several
As was noted in [17], the solutions proposed by Stewart and Frame lacked
ues for m we obtain a minimal solution, became later known as the ”Frame-
Stewart conjecture”, and is still open. Knuth expressed his opinion on the
truly difficult.” (cf. [32]). Employing exhaustive search, it has been verified
A time analysis of the algorithm yields, that the growth rate of the number
h−3 1
of moves is bounded by the sub-exponential expression O(n h−2 2n
h−2
) [40].
The lower bound issue has been discussed in [42], where a sub-exponential
1
1 12
bound of 2 2 (1±o(1))( h(h−1) n)
h−2
was obtained. Recently, that bound has been
1
(1±o(1))((h−2)!n) h−2
improved to 2 in [13].
Several researchers considered Hanoi graphs in which disk moves can be per-
formed only along the edges. The earliest known version is the three-in-a-row,
8
Three−in−a−row
Complete Cyclic
Complete−− Cyclic++
described in [38] and [40], where there are pegs 1,2,3 and peg 1 is connected to
peg 2 bi-directionally, the same between pegs 2 and 3, but no edges between
pegs 1 and 3.
In [4], the Cyclic version, in which the pegs are ordered in a circle, and
at each move we are allowed to move a disk from one peg to another only in
vertices are discussed thoroughly in [37], see Figure 1.2. The same author
presents asymptotic bounds for the number of moves in the Cyclic version
(SCC) of size three, a path to one of its nodes and an edge from S to that
node were studied, an algorithm was suggested, and its optimality proved
9
[7].
The problem of starting from any specified legal configuration and ending
with another specified one was suggested in [18]. A nice recursive algorithm
Given a Hanoi graph, a question may arise: how many disks can be moved
from source to destination? Theorem 1.2.1 states the necessary and sufficient
condition for the existence of a solution. For Hanoi graphs not satisfying
the condition in the Theorem, the number of disks has been shown to be
1
maximally of the order of h 2 log2 h in [6]. The same paper also gives a char-
[30]).
venient, but not to create more situations like this in the course of
(see [26]).
10
This issue has been dealt with by several researchers (cf. [15]).
on each peg a tower of disks of a certain color is placed, and the task is to
replace the pegs on which the disks reside. In [33], the number of moves the
consisting of two towers of disks has been proposed and solved in [40]. The
same author also proposed the Rainbow problem [38], in which there is just
one tower of disks of several colors, and at no stage are two disks of the same
code: the sequence of bit numbers that change, when moving from a code-
of the disks moving at each stage in an optimal solution [21]. The following
writing down the Pascal Triangle with 2n rows, deleting the even numbers,
and drawing edges between neighbouring numbers, one obtains the struc-
ture of the Hanoi configuration graph for n disks. This and more analogies,
searchers were interested in finding the average distance between any two
configurations ([19, 12, 24]). Another question is ”what is the minimal num-
ber of moves the largest disk has to make in an optimal solution?” It receives
tasks), being greedy with respect to the largest disk, we may be led to a
non-optimal solution. The complexity of finding out whether the largest disk
Iterative Algorithms
sion of) this problem is much more difficult. Besides being a programming
12
lution. For example, the amount of moves each disk performs in the classical
Hanoi version is much clearer when observing an iterative solution than when
Other researchers (cf. [22], [11]) also discussed the iterative solution to the
general problem.
Sequences of Moves
generate an infinite sequence such that the optimal solution to the classical
version, for any number of disks, appears as a prefix of that sequence [2].
moves. In [18] and [23] it has been shown that the perfect task of the classical
13
problem requires more moves than any task between non-perfect configura-
tions. However, this is not always the case. Consider K4 and 15 disks, where
whereas Korf [27] found non-perfect configurations that require 130 moves
component (or in short SCC) to a vertex, we get the graph H SCC = (V SCC , E SCC ),
D. Azriel [5] studied AAG2. Solvable graphs begin from AAG3. So, we
graph investigation.
too difficult. For example, in [7] there is a complicated proof for the exact
bound for a very particular case. Also in [5] there are non-matching lower
n
(i) Suggesting algorithms of length ≈ 2 f (`) , where n is the number of disks.
(ii) Proving asymptotic lower-bounds for g(n), where the minimal number
n
of moves is 2 g(`) .
(iii) The bounds in (i) and (ii) are defined by recurrences, so we advance
– Trying to give analytical formulas for a lower bound for f (`) and
– Trying to estimate the gap between f (`) and g(`) by using the
recurrences.
In other words, we look for upper and lower bounds for the logarithm of
n
the minimal number of steps (to be more precise, for log2 (time)
). We look for
In this thesis, we use a special variant O` (·) of the O(·) notation. For a
given function g(n), we say that f (n) = O` (g(n)) if there exist a function
c(`), depending on ` only, and a constant n0 such that f (n) ≤ c(`) · g(n) for
all n ≥ n0 .
Our algorithms are of a quite restricted class. They are based on a fixed,
but not given a-priori, division of the n disks to blocks of consecutive disks,
15
and moving those blocks during the algorithm, block by block. The blocks
There is some similarity between the work of D. Azriel on AAG2 [5], and
our research. One might think of a disk in the model of [5] as the counterpart
of a block of disks in our model. Likewise, our ”best” Hanoi graph H`T C and
the idea of first moving the disks to the ”middle” node, which was quite
natural in [5].
[5] for general AAG3. We note that direct generalizations of the lower bound
techniques of [5] were applicable only for block-algorithms. It was the insight
algorithms.
In Chapter 3 we deal with the most connected AAG3 H`T C , which provide
M ovetc for them. We also provide a recurrence describing its running time,
16
and give an explicit expression bounding the function defined by it. It implies
n
a running time of O` (2 f (`) ), where for each ε > 0 there exists a constant
On the other hand, we provide a recurrence for a lower bound, and give
for each `. Finally, by studying the relation between the two recurrences, we
g(`)
prove the upper bound of 6 · `log2 3 < 6 · `1.6 for the ratio f (`)
, which is of a
1 log `
C` 2 C
lesser order than the order of magnitude of = · `ε log ` .
C ε `( )
1 −ε log `
2
Cε
among AAG3` , with the maximal number of steps in the optimal algorithm.
the end of this section, we generalize our results to Hanoi graphs ”parallelly-
We provide recurrences for upper and lower bounds, which have a form sim-
ilar to that in Chapter 3. We were unable to estimate the gap between the
lower and upper bound, in the general case. Although, we believe them to
a matrix with h rows and w columns. Matrix graphs are in a sense the
where for each ε > 0 there exists a constant Cε > 0, such that f (h, w) ≥
1
Cε · w · h( 2 −ε) log h for each h ≥ 1. On the other hand, we got a lower
n
bound of Ω` (2 g(h,w) ), where there exists a constant C, such that g(h, w) ≤
1
Cwdlog he+1 h 2 log h for any w, h ≥ 1. Finally, by studying the relation between
the two recurrences, we prove the upper bound of 6 · hlog2 3 < 6 · h1.6 for
g(h,w)
the ratio f (h,w)
, which is of a lesser order than the order of magnitude of
1
Cwdlog he+1 h 2 log h C
1 = Cε
· wdlog he hε log h .
Cε ·w·h( 2 −ε) log h
In our work we focus on Hanoi graphs built from complete SCCs of size three,
i.e., K3 . Note that all graphs with a single SCC of size three are studied by A.
(a) All SCCs are of the same kind. We believe our approach could be
(b) There are SCCs of different kind. In [37], it is proven that the
(a) All SCCs are of the same kind. Our believe is similar to that in
item 2a.
(b) There are SCCs of different kind. We can define the relation
4. What may be the influence of canceling the restriction that we use for
5. We were able to estimate the gap between the lower and upper bounds
recurrence for computing the lower-bound for H (which is true for the
6. Small-but-interesting questions:
(a) Our general algorithm M ovegen and general lower-bound are based
(c) Finding exact solutions for small Hanoi graphs, such as a graph
Preliminaries
belonging to C.
r
A move of disk r from peg u to peg v is denoted by u −→ v. Obviously,
a configuration of D\{r} is the same before and after such a move; we refer
r
to it as the configuration of D\{r} during u −→ v.
20
21
moves between these moves, including the former move but not the later one
r r0 r r0
is denoted by P [u −→ v, u0 −→ v 0 ), or simply [u −→ v, u0 −→ v 0 ) if the move
r r0
sequence is clear from the context. Similarly P (u −→ v, u0 −→ v 0 ) denotes the
subsequence of P between these moves, excluding the former and the later
For any configuration C and disk set D, let us define the restriction of
that the restriction of any legal sequence of moves to any disk subset is legal.
Thus, for any two disk sets D 0 ⊂ D and any move sequence P of D, the
holds.
each disk set Di reside on Si , and in the final configuration each Di reside
22
Pk
on Di . Observe that any solution S of such a task requires at least i=1 ti
steps, since for any i, the restriction S |Di contains at least ti steps.
sequence in which the i’th move of P is the (|P | + 1 − i)’th move in P (e.g.
We use the notation I(Hij ) to indicate the set of indices of the components
in C(Hij ).
with it’s index, e.g., for two blocks Bi and Bj , we say that Bi > Bj , if i > j.
quences of moves of disks by paths of H. Thus (m, p), where p is the path
(e1 , e2 . . . , et ), ei ∈ E, signifies that disk m first moves from the starting point
B
Ci v1 v2 v3
move−path p
Cj u1 u2 u3
It is easy to see that any block-move is legal, see Figure 2.1 for a block-
move illustration.
We call the path used to transfer the disks between the two components
algorithm.
defined in the previous section for them, e.g., using the interval notation and
from Ci to Cj to be possible.
Proof: If the condition in the observation is met, than we can use a block-
move of the type that uses the guaranteed free component as the sorting-
component.
26
to the second restriction, any block-move transfers only disks which belong to
due to Theorem 1.2.1. In other words, we can transfer only a finite amount
cost of the latter transfer is m · (|p| + 1). Hence, the proposition follows. 2
In this thesis, all our block-algorithms are a special case of the algorithm
M ovegen presented in Chapter 5, and they all have the following properties:
Proof: Since H SCC is a DAG, the number of times each block is moved
(2m − 1) + m · (|p| + 1). Since we have k blocks, with at most d nk e disks each,
where c(`) = O(log2 `). The second inequality in the above chain is equivalent
to:
n
3k` · 2d k e ≥ 3`n,
n
k · 2d k e ≥ n,
n n
2d k e ≥ .
k
The last inequality follows from the known inequality 2x > x for any x ≥ 0.
The bound c(`) = O(log2 `) follows from the bound k(M oveT C , H`T C ) =
1
O(` 2 log ` ) proved in Theorem 3.2.1. 2
Observation 2.2.7 For any Γ0 < Γ, if there exists a block-algorithm moving
Γ blocks from Ci to Cj , then there exists a block-algorithm moving Γ0 blocks
from Ci to Cj .
28
Ci Ci
S v1 v2 v3 D S v1 v2 v3 S v1 v2 v3
max
H1 H2 H2
D u1 u2 u3 D u1 u2 u3
Cj Cj
Indeed, the restriction of the given algorithm to the disks in the first Γ0
In this section we study the basic graphs H1 , H2 and H2max (see Figure 2.2)
though the following claims could easily be adjusted to any source from Ci
Claim 2.3.1 For a given configuration, the maximal number of blocks, which
a block-algorithm can transfer inside H1 is one block.
Proof: Observation 2.2.2 implies that for BM(a) , we can transfer only the
smallest block inside the component. Since only one such block exists, the
Proof: When disk n moves from v1 to w.l.o.g v2 , all other disks are gathered
2n−1 . 2
In this section we prove some basic mathematical results that would be useful
in further chapters.
Lemma 2.4.1 Consider the following two recurrence relations (an )∞
n=1 and
∞
(bn )n=1 which satisfy:
an = an−1 + kad n2 e (2.1)
bn = bn−1 + λkbd n2 e .
bn b1 dlog ne
For each n ≥ 1, where λ ≥ 1 and k ≥ 0, an
≤ a1
λ .
way:
b1 dlog ne
cn = λ an .
a1
30
bn cn b1
≤ ≤ λdlog ne .
an an a1
Induction Step: Assume the correctness of the claim for all values of
≥ cn−1 + λkcd n2 e .
2
31
P
k
Lemma 2.4.2 Let F (x1 , . . . , xk ) = fi (xi ), where each fi is a continu-
i=1
ously differentiable convex function. The conditional minimum of F with the
Pk
constraint xi = n, is achieved at point (x1 , x2 , . . . , xk ) satisfying f10 (x1 ) =
i=1
f20 (x2 ) = . . . = fk0 (xk ).
any point (where ∇g is the gradient). So, we can use Lagrange multipliers,
s.t.:
∇F = −λ∇g,
∂F dfi
= = −λ.
∂xi dxi
This shows that all fi0 are equal. From the fact that all fi are convex
real minimum rounded with ceilings and floors. For example, for the function
P
F = 6i=1 5x2i + x27 with n = 35, the minimum is achieved at xi = 3 11 2
for
1 ≤ i ≤ 6, and x7 = 15 10
11
, whereas the discrete minimum is achieved at
P
k
Proposition 2.4.3 Consider a function F (n1 , . . . , nk ) = fi (ni ), where
i=1
ni
+bi P
k
each fi satisfy fi (ni ) ≥ 2 ai , ni = n, and ai and bi are some constants.
i=1
³ ´
n s2
− −log s1
1. The minimal value of F , min F , satisfies min F ≥ 2 s1 s1
, where
P
k P k
s1 = ai and s2 = ai (log ai − bi ).
i=1 i=1
n
2. In the special case where ∀i, ai = a, bi = b, min F ≥ 2 k·a +b .
ni
+b
Proof: Let gi (ni ) = 2 ai i , for each 1 ≤ i ≤ k, and G(n1 , . . . , nk ) =
Pk
i=1 gi (ni ). From Lemma 2.4.2, we get that any vector (n1 , n2 , . . . , nk ) which
yields the minimal value for G, satisfies g10 (n1 ) = g20 (n2 ) = . . . = gk0 (nk ).
P
k Pk
Let s1 = ai and s2 = ai (log ai − bi ).
i=1 i=1
We set
ai (n − s2 )
ni = + ai (log ai − bi ).
s1
The vector (n1 , n2 , . . . , nk ) has the following properties.
P
k P ³ ai (n−s2 ) ´ P
ai (n−s2 )
1. ni = s1
+ ai (log ai − bi ) = s1
+ s2 = n.
i=1
ni n−s2 n−s2
ln 2 +bi ln 2 +(log ai −bi )+bi
2. ∀i, gi0 (ni ) = ai
· 2 ai = ai
·2 s1
= ln 2 · 2 s1
. Thus,
Substituting it in G we get:
Xk µ ³ ´ ¶ Xk µ ³ ´¶
ai (n−s2 ) s
+ai (log ai −bi ) a1 +bi n
+ log ai − s2
min F ≥ min G ≥ 2 s1 i = 21
s 1
i=1 i=1
à k !
X n s
− s2 n s
− s2 n s
− s2 +log s1
= 2log ai · 2 s1 1 = s1 · 2 s1 1 = 2 s1 1 .
i=1
33
n s k·a(log a−b)
− s2 +log s1 n n n
2 s1 1 = 2 k·a − k·a
+log k·a
= 2 k·a +b+log k ≥ 2 k·a +b .
1. In Section 3.1, we find the Hanoi graph H`T C with ` components, s.t.
recurrence for the number of its steps, which is an upper bound for the
of steps required for solving H`T C , and thus of any Hanoi graph in
AAG3` .
above for our upper and lower bounds (which remain implicit, as for
34
35
C1 S
C2
C3
C4 D
5. In Section 3.5, we find explicit upper and lower bounds for the number
V (H`T C ) = {vij : 1 ≤ i ≤ `, 1 ≤ j ≤ 3}
The number of SCCs in H`T C is `, where SCC Ci = {vi1 , vi2 , vi3 }. In Figure
3.1 we depict H4T C . To avoid over-congestion, we draw only the edges between
vertices belonging to the same Ci or to consecutive Ci0 s, but there are actually
Proof: Notice that adding edges or vertices to Hanoi graph H can only de-
crease the number of steps required to solve HAN (H, n). For an arbitrary
Hanoi graph with `(H) = `, we can perform a topological sort V SCC → [1..`]
note the vertices in Ci (H) by vik , for 1 ≤ k ≤ |V (Ci )|. Since H ∈ AAG3` ,
TC
V (H`,ij ) = {vst : i ≤ s ≤ j, 1 ≤ t ≤ 3},
TC
E(H`,ij ) = {(vst , vxy ) : (s ≤ x)}.
TC
Note that H`,1` = H`T C , and that H`,ij
TC TC
is isomorphic to Hj−i+1 . Notice that
Theorem 3.2.1 1. Algorithm 3.1 solves HAN (H`T C , n), while satisfying
having the properties of Assumption 2.2.4 for any ` and n.
37
b2 = b1 = 1
b` = b`−1 + bd ` e , ` ≥ 3,
2
n
+c(`)
so that the number of its steps is at most 2 b` , for some function
c(`).
3. For each ε > 0 there exist a constant Cε > 0, such that b` ≥ Cε `( 2 −ε) log `
1
for each ` ≥ 1.
TC
Algorithm 3.1 M ovetc (H1` , S, D)
1: if ` = 1 or ` = 2 then
2: transfer one block from S to D using BM(a) or BM(b) accordingly.
3: else
TC
4: M ovetc (H1d ` , S, vd ` e1 ).
e 2 2
TC
5: M ovetc (H1` \{Cd ` e }, S, D).
2
6: M ovetc (HdT`Ce` , vd ` e1 , D).
2 2
7: end if
assume its correctness for all `0 < ` and prove correctness for `. In Line 4
above transfers are legal due to the induction hypothesis. It is easy to see
that the algorithm has the properties of Assumption 2.2.4. Thus, item 1
follows.
38
This section develops a lower bound for the number of steps needed to solve
Theorem 3.3.1 1. The minimal number of steps required to solve HAN (H`T C , n)
n
−c(`)
by any algorithm is 2 a` , for some function c(`), where (a` )∞
`=1 is de-
fined by the recurrence:
a1 = 1, a2 = 2
a` = a`−1 + 3ad ` e , ` ≥ 3.
2
1
2. There exist a constant C, such that a` ≤ C` 2 log ` , for each ` ≥ 1.
Proof:
n
−c (`)
Lemma 3.3.2 If in an empty H`T C , at least 2 c1 (`) 2 steps are required
to transfer n disks from vik1 to vjk2 , where k1 , k2 ∈ {1, 2, 3}, then at least
n
−c (`)
2 3c1 (`) 2 steps are required to transfer n disks from vik1 to some configura-
tion in Cj , or to transfer n disks from any configuration in Ci to vjk2 .
Proof: Let Alg be some sequence transferring n disks from vik1 to Cj . Let
us look at the configuration just after Alg finished executing, and denote the
P
3
By the assumption of our lemma and Proposition 2.4.3(2), |Alg| = |(Alg|Ah )| ≥
h=1
P
3 nh
−c2 (`) n
−c2 (`)
2 c1 (`) ≥ 2 3c1 (`) .
h=1
The second argument follows from symmetry. 2
Basis: ` = 1, 2.
steps to solve.
40
From Claim 2.3.3, the minimal number of moves required to move the q
disks in C1 before the first move of disk n, is at least 2q−1 . In a similar way
after the last move of disk n is 2n−q−2 . Altogether we have 2q−1 + 2n−q−2
moves. A simple calculation shows that the minimal value of this function is
n−3 n−3 n
2b 2
c
+ 2d 2
e
≤ 22.
Induction Step: Assume the correctness of the claim for all values of `0 < `
Let us look at the configuration of Dn \ {n} during the first move of disk
Claim 2.3.3, the minimal number of moves required to transfer n1 disks from
to v`1 = D is 2n` −1 .
d 2` e
P P
`−1
Let s(`) = 3ai (log ai +c(i))+ 3a`+1−i (log a`+1−i +c(` + 1 − i))−
i=2 i=d 2` e+1
2.
Altogether, we get from Proposition 2.4.3 (1) the following lower bound:
`
d2e `−1
X ni
−c(i)
X ni
−c(`+1−i)
2 3ai
+ 2 3a`+1−i + 2n1 −1 + 2n` −1
i=2 i=d 2` e+1
n−1 s(`) n s(`)
− a +log a` − a1 − +log a` n
−c(`)
≥ 2 a` ` = 2 a` ` a`
= 2 a` .
s(`)+1
where c(`) = a`
+ log a` and a` satisfies:
b 2` c
P
2 3ai + 2 ` ≡ 0 (mod 2),
i=2
a` =
b 2` c
P
2 3ai + 3ad ` e + 2 ` ≡ 1 (mod 2).
2
i=2
number of moves required to solve HAN (H, n). On the other hand, we
n
introduced a block-algorithm solving the problem with O` (2 b` ) steps. We
other.
42
a`
Claim 3.4.1 For each ` ≥ 2, b`
≤ 2 · 3dlog `e < 6 · `log 3 .
a2 = 2, b2 = 1,
b` = b`−1 + bd ` e , ` ≥ 3,
2
a` = a`−1 + 3ad ` e , ` ≥ 3.
2
claim. 2
of a lesser order than the order of the ratio of our previous upper and lower
1 log `
C` 2 C
bounds = · `ε log ` .
Cε `( )
1 −ε log `
2
Cε
The techniques used in this section to acquire the lower and upper bounds
Proof: Let ε > 0. Obviously, the lemma is true for ε ≥ 12 , so we may assume
ε < 12 . Set
1 − 2ε
α=
2 ln 2
`2ε C
and let L0 be the minimal number ` for which ln(`+1)
≥ 2α ln 2
, where C is
µ ¶α ln( `+1
2 )
α ln ` `+1
b`+1 ≥ b` + bb `+1 c ≥ Cε ` + Cε .
2 2
The second term on the left-hand side of (3.2) may be bounded from
below by:
µ ¶α ln( `+1
2 )
µ ¶α ln( 2` )
`+1 ` `α ln ` 2α ln 2
≥ = (3.3)
2 2 `2α ln 2
Using the inequality ln(1 + 1/`) ≤ 1/`, we estimate the right-hand side
of (3.2),
α ln `(`+1)
≤ `α ln ` e `
α ln(`+1)
≤ `α ln ` e3 `
· µ ¶¸
α ln ` ln(` + 1)
= ` 1+O (3.4)
`
· ¸
α ln ` ln(` + 1)
≤ ` 1+C ,
`
44
for a suitable C. To prove (3.2) it suffices, by (3.3) and (3.4), to show that
· ¸ · ¸
α ln ` α ln 2 1 α ln ` ln(` + 1)
` 1+2 ≥ ` 1+C , ` ≥ L0 .
`2α ln 2 `
`1−2α ln 2 `2ε C
= ≥ α ln 2 , ` ≥ L0 ,
ln(` + 1) ln(` + 1) 2
Set
1
α=
2 ln 2
3 2e ( e )
√ 4α 1 +1
and let L0 be the minimal number ` for which the constant α
≤
ln `(` + 1). Take C so that the required inequality holds for all ` < L0 .
1
Assume inductively that ak ≤ Ck α ln k = Ck 2 log k for each 0 ≤ k ≤ ` for some
`+1
` + 1 α ln d
α ln `
2
e
a`+1 = a` + 3ad `+1 e ≤ C` + 3Cd e (3.5)
2 2
µ ¶α ln( `+2
2 )
` + 2
≤ C`α ln ` + 3C .
2
45
The right-hand side may be bounded from below using Bernoulli inequal-
ity:
µ ¶α ln(`+1) µ ¶α ln(`+1)
α ln(`+1) α ln(`+1) 1 α ln ` α ln(1+ 1` ) 1
(` + 1) = ` 1+ =` ` 1+ (3.7)
` `
µ ¶α ln ` µ ¶α ln(`+1) µ ¶α ln `(`+1)
α ln ` 1 1 α ln ` 1
= ` 1+ 1+ =` 1+
` ` `
µ ¶
α ln `(` + 1)
≥ `α ln ` 1 + .
`
and we have
µ ¶α ln(`+2)
2
`α ln(1+ ` ) = `α ln ` eF (`) ,
2
α ln(`+2) α ln `
(` + 2) =` 1+
`
where
µ
¶ · ¸ µ ¶
2 2 2
F (`) = α ln 1 + ln `(1 + ) + α ln ` ln 1 +
` ` `
µ ¶· µ ¶¸
2 2
= α ln 1 + 2 ln ` + ln 1 +
` `
46
for ` ≥ 1:
· ¸ · ¸ · ¸
4α 1 1 1 1
F (`) ≤ ln ` + ≤ 4α + ≤ 4α +1 .
` ` e `2 e
Altogether we have:
µ ¶α ln( `+2 √
2 ) `α ln ` e4α( e +1) 2
1
`+2 `α ln `
3 ≤3 = C0 . (3.8)
2 ` `
Replace the right-hand side of (3.6) by that of (3.7) and the second term
on the left-hand side by the right-hand side of (3.8). We get the stronger
inequality:
µ ¶
α ln ` `α ln ` α ln ` α ln `(` + 1)
` + C0 ≤` 1+ , ` ≥ L0 ,
` `
√
3 2e4α( e +1)
1
C0
= ≤ ln `(` + 1), ` ≥ L0 .
α α
2
Chapter 4
Complexity of
Parallel-Components Hanoi
Graphs
edge from S to each component, and another directed edge adjacent to the
For the sake of completeness we give the classic algorithm, solving the original
47
48
PCl
H1
S
S
PC1
D P1 P2
S
C1 P1 P2 P3
C1 C2 Cl H’1
D S
P1 P2 P3
D
Now let’s look at H10 , as depicted in Figure 4.1, with the complete com-
ponent denoted as C1 . This time our goal is to move the disks from a perfect
Proof: Let Alg1 (n) be some optimal algorithm, transferring n disks from
n
disks reside in C1 . Alg1 (n) must contain the move S −→ P2 , and since the
algorithm is optimal, every move after this move is redundant. So this is the
last move of Alg1 (n). During the move, peg P2 must be free.
n−1
1. S −→ P2
n−1
2. A2 −→ Pi (i=1 or 3, wlog i=1).
During the second move, all other disks must be gathered on peg P3 . So
we have that |Alg2 (n−1)| ≥ |M oveH1 (n−2, S, P3 )|+2. Therefore |Alg1 (n)| ≥
2n−2 + n.
We have proven that each optimal algorithm solving the problem, contains
Proof: Let’s prove that the proposed algorithm is indeed optimal. Let Alg
1 n
1. Alg[S −→ P2 , S −→ P2 ].
n n
2. Alg(S −→ P2 , P2 −→ D).
n 1
3. Alg[P2 −→ D, P2 −→ D].
We notice the facts, that right after the first part, and right before the
third part of the algorithm, all disks reside in C1 . Thus, due to Proposition
4.1.1:
1 n
1. |Alg[S −→ P2 , S −→ P2 ]| ≥ |M oveH10 (n, S, C1 )|.
n 1
2. |Alg[P2 −→ D, P2 −→ D]| ≥ |M oveH 0 (n, D, C1 )|.
1
This implies |Alg| ≥ |M oveP C1 (n, S, D, C1 )|, as required. This also implies
n−2 n−2
(2 + n) by Proposition 4.1.1. Therefore |M oveP C1 | = 2 ∗ (2 + n) =
2n−1 + 2n.
Let Alg be some algorithm solving P C` , and let Ai be the group of disks
that resided at some time during the algorithm in Ci . Let ni = |Ai |, and
T
1. ∀i 6= j, Ai Aj = ∅. This stems from the structure of the graph. Thus
P
ni = n.
P
2. |Alg| = f (Ai ) stems from the definition.
From the above facts we can get the following lower bound.
1
P
Corollary 4.1.3 Any algorithm solving P C` contains at least 2
2ni + 2n
moves.
P P
Proof: Let Alg be such algorithm. Then |Alg| = f (Ai ) ≥ 2 ∗ (2ni −2 +
P
ni ) = 21 2ni + 2n. 2
Theorem 4.1.4 The following algorithm M oveP C` (n, S, D) is an optimal
n
algorithm solving P C` , and it takes (` + r)2b ` c moves, r ≡ n (mod `).
2: for i = 1 to ` do
3: transfer ni disks from S to Ci using M oveH10 (n, S, Ci ).
4: end for
5: for i = ` downto 1 do
6: transfer ni disks from Ci to D using M oveH 0 (n, D, Ci ).
1
7: end for
Proof: The algorithm matches the bounds in Corollary 4.1.3, i.e. |M oveP C` | =
1
P ni
2
2 + 2n. We need to proof that the chosen values for the ni variables
P
minimize the expression 12 2ni + 2n.
53
ni > nj . Therefore:
2ni + 2nj = 2ni −1 + 2ni −1 + 2nj > 2ni −1 + 2 ∗ 2nj = 2ni −1 + 2nj +1
algorithm, contradiction.
if and only if, r arbitrary ni variables get the value d n` e, while the rest of the
discussed in Chapter 5.
We study Hanoi graphs which are composed of ` ”parallel” Hanoi graphs, for
[
V P ar = Vi ∪ {S, D}.
i=1,... `
54
S1 S2 Sk
H1 H2 Hk
D1 D2 Dk
Let Alg be some algorithm solving H P ar , and let Ai be the group of disks
P P
Proof: |Alg| = |(Alg|Ai )| ≥ (fi (ni ) + 2 ∗ ni ) this is due to definitions
We define the sequence Opt0i as Opti with the following two changes:
j
1. Replace the first move Si −→ v of disk j with two consequent moves
j j
S −→ Si and Si −→ v.
55
j
2. Replace the last move v −→ D of disk j with two consequent moves
j j
v −→ Di and Di −→ D.
Claim
P 4.2.2 The following algorithm M oveH P ar (n, S, D) solves H P ar with
fi (ni ) + 2 ∗ n moves.
1. ni ≥ 0 for each i = 1, . . . , `.
P̀
2. ni = n.
i=1
56
O(`n2 ) steps, under the assumption that computing fi (m) for some m takes
O(1) operations.
P
i
1. min fj (nj )
j=1
P
i
2. nj = s.
j=1
f (s) if i = 1
1
mat[i, s] =
min {mat[i − 1, `] + fi (s − `)} otherwise.
1≤`≤s
bound of O(`n2 ) for computing the value of mat[`, n], and the corresponding
definition.
can find that point, and round the results to get an approximate discrete
solution. For example, consider a particular case, where the Hanoi graph
conjecture.
f1 (n1 ) = 2n1 − 1.
√
2n2 √
f2 (n2 ) = 2 ( n2 − 1) + 1.
58
√
x1 ≈ 2x2
x1 + x2 = n
p p
x1 = 2(n + 1) − 1, x2 = n − 2(n + 1) + 1.
We use ceiling and floor to round the results (we have only 2 options, so
for ”storage”.
59
60
case. We provide an upper and a lower bound for them and show that
We study general Hanoi graphs H, within the family AAG3` , with all SCCs
sort of H SCC i.e., if there’s a directed path from Ci to Cj in H SCC , then i < j.
We denote the vertices of Ci by {vi1 , vi2 , vi3 }. We also assume that S = v11
and D = v`1 .
all the vertices vix , i ∈ {1, . . . , `}, does not effect the graph H SCC . More
formally:
W.l.o.g. let us assume this vertex is vi1 , for each i ∈ {1, . . . , `}. If there
is a path from vi1 to vj1 in H, which does not contain the vertices vk1 , for
i < k < j. Let us denote this path by p(i, j). We note that the possibility
of transferring disks from vi1 to vj1 via p(i, j), does not depend on whether
61
X S
X X
X X
X D
the vertices vk1 , i < k < j, are free of disks or not. See Figure 5.1 for an
example.
Our algorithm 5.2 M ovegen (H, 1, `) is parameterized by values kij (H). They
are computed by Algorithm CompP ar(H). In particular ki` (H) is the num-
ber of blocks used by M ovegen (H, 1, `). We denote P (Hij , Ch ) = min{kih (H), khj (H)}
where h ∈ I(Hij ) and h 6= i, j. We note that our algorithm has the property
Theorem 5.2.1 Algorithm M ovegen (H, r, q) is correct for any graph H, sat-
isfying assumption 5.1.1, and it transfers krq blocks from vr1 to vq1 , having
the properties of Assumption 2.2.4.
62
Proof:
It is easy to see that Algorithm 5.2 transfers k1` (H) blocks from S to D,
For `(H) = 2, k12 (H) = 1, and algorithm BM(b) (from Chapter 2) indeed
Let us assume correctness for all graphs H of size smaller than `. Let
definition, P (H, Ci ) ≤ k1i (H), hence we can transfer P (H, Ci ) blocks from S
that disk m first moves from the starting point of e1 to the endpoint of e1 ,
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
Empty
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
S M M
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
i j
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
000000000000000000000000000000000000000000
111111111111111111111111111111111111111111
but Mi 6= Mj .
destination v(Mj ) instead of v(Mi ), in the following way: For all block-moves
from v(Ch ) to v(Ci ), with move-path p, replace p, with (p(h, j) ∪ (vjs , vjd )),
where vjs is the last vertex in p(i, j), and vjd is the last in p. Replace every
From the construction of Alg 0 , it is clear that all the block-moves in Alg
Mj . We note that in the end of Alg 0 all disks are gathered on v(Mj ), since
in Alg they are gathered on v(Mi ), and Alg 0 mirrors Alg actions from Mi to
65
The idea behind the rest of the correctness proof is that at any stage
Basis: i = 1, 2.
are filled. Line 7 is possible by using BM(b) , extended via the path p(1, `).
Observation 5.2.4 For all i ∈ {1, . . . , ` − 2}, the configurations just after
executing line 5 and just before executing line 9 are identical, except for C1
and C` .
set of the largest blocks in C` instead of C1 , which does not obstruct moves
lines 8-9, it is sufficient to show that there exists a sequence to empty it,
67
components.
Destination(H) = S.
fore, applying Alg in the reverse order, just after Alg filled Mi , i.e., in config-
the algorithm. So, Algorithm 5.2 is legal and it transfers k1` (H) blocks from
S to D. 2
In this Section, we prove that the parameter k1` (H), computed in the previous
section, is the maximal number of blocks we can transfer from v(C1 ) to v(C` )
stage when this block-move is carried out, C` is empty. Since otherwise, just
68
after Bk moves later to C` , C` contains (at least) two blocks on two different
pegs, contradicting Assumption 2.2.4. So, we can change the given solution
p(1, `), and continue with all block-moves of the original algorithm, omitting
block-moves of Bk .
Notice that, up to the first block-move of Bk , the two sequences yield the
same configurations of blocks on H. From that point on, the only difference
can transfer from vi1 to vj1 under the restrictions of Assumption 2.2.4 in an
empty graph.
ness of the proposition for all Hanoi-graphs of size smaller than `. Consider
69
From the induction assumption k(H1i , C1 , Ci ) = k1i (H1i ) = k1i (H), similarly
at the stage when the largest block is moved from C1 to C` does not ex-
ceed min{ki1 (H), ki` (H)} = P (H, Ci ). Hence the total number of blocks
k(H, C1 , C` ) satisfies:
X
k(H, C1 , C` ) ≤ P (H, Ci ) + 1.
Ci ∈C(H),i6=1,`
the number of moves required by any algorithm to solve HAN (H, n).
Theorem 5.4.1 The minimal number of steps of any algorithm solving HAN (H, n)
n
is 2 g(H) −c(`) , for some function c(`), where g(H) = g(H1` ) is defined by Re-
currence 5.3.
Basis: ` = 1, 2.
70
minimum on the empty set is set to zero. Let us look at the configuration of
Dn \ {n} during the first move of disk n. Let us denote the number of disks
From Claim 2.3.3, the minimal number of moves required to move the q
disks in C1 before the first move of disk n, is at least 2q−1 . In a similar way
after the last move of disk n is 2n−q−2 . Altogether we have 2q−1 + 2n−q−2
moves. A simple calculation shows that the minimal value of this function is
n−3 n−3 n
2b 2
c
+ 2d 2
e
≤ 22.
Induction Step: For ` ≥ 3, assume the correctness of the claim for all values
of `0 < ` and for all n, and prove it for ` and for all n.
Let us look at the configuration of Dn \ {n} during the first move of disk
for some function c1 (i). Similarly, the minimal number of moves required to
ni
−c2 (i)
move ni disks from vi1 ∈ Ci to D is at least 2 g(Hi` ) , for some function
71
c2 (i).
Using Lemma 3.3.2, we get that for i ∈ {2, . . . , `−1}, the minimal number
ni ni ni
−c1 (`) −c2 (i) −c(i)
2 3g(H1i ) + 2 3g(Hi` ) ≥ 2 3 min{g(H1i ),g(Hi` )} ,
Altogether, we get from Proposition 2.4.3 (1) the following lower bound:
`−1
X ni n−1 s(`) n
−c(i) − g(H +log(g(H1` )) −c(`)
2 3 min{g(H1i ),g(Hi` )} +2n1 −1 +2n` −1 ≥ 2 g(H1` ) 1` ) ≥ 2 g(H1` ) ,
i=2
where
`−1
X
s(`) = mi (log mi − c(i)) − 2, mi = min{g(H1i ), g(Hi` )},
i=2
s(`) + 1
c(`) = + log(g(H1` )).
g(H1` )
We note that our pair of recurrences for upper and lower bounds are
believe our pair is also tight, but could not prove it.
h rows and w columns of components, and two separate components for the
source and destination. For each component, there are edges between all it’s
72
w
C 0,1
C 2,1 C 2,w
h Ci,j
C h−1,1 C h−1,w
Cf,k
C h,1 C h,w
∀i < f
C h+1,1
vertices and all the vertices belonging to ”lower” rows. See Figure 5.3 for an
mat
C(Hhw ) = {Ci,j ∪ C0,1 ∪ Ch+1,1 : 1 ≤ i ≤ h, 1 ≤ j ≤ w}
mat
E(Hhw ) = {(u, v) : (u, v) ∈ Ci,j or (u ∈ Ci,j , v ∈ Cf,k , where i < f )}.
4.
73
mat
Let us denote g(Hhw ) by bhw , where function g is defined in Theorem 5.4.1.
Proof: For b0w we get the graph H2max , which satisfies g(H2max ) = 2, by
1
Proposition 3.3.4. For b1w , using Recurrence 5.3, we get:
w
X
mat
b1w = g(H1w ) = 3 min{g(H(0,0),(1,j) ), g(H(1,j),(2,1) )} + 2
j=1
Xw
= 3w min{b0w , b0w } + 2 = 3w · b0w + 2.
j=1
We can show the correctness of our claim from (5.1) by using a technique
1
Proposition 5.5.2 There exists a constant C, such that bhw ≤ Cwdlog he+1 h 2 log h
for any w, h ≥ 1.
1
b1w = 6w + 2 ≤ 7w = 7wdlog 1e+1 1 2 log 1 .
a2 = 2.
ah = ah−1 + 3ad h e , h ≥ 3,
2
1
and showed in Theorem 3.3.1 (2) that ah ≤ C2 h 2 log h for any h ≥ 2, where
= 3w · b0w + 2 + 3w · b0w
= 12w + 2.
≤ bh−1,w + 3w · bd h e,w , h ≥ 3.
2
b2 dlog he 1
bhw ≤ w ah ≤ C1 (6w + 1)wdlog he h 2 log h
a2
1
≤ 7C1 wdlog he+1 h 2 log h .
Summarizing, the statement holds for C = max{7, 7C1 } in the entire range
of parameters. 2
75
bhw for specific values of α, then we study bhw for general α. We finish by
By Proposition 5.5.2.
For the two boundary and the middle pairs (w, h) we have:
• α = 0 ⇒ w = `, h = 1,
bh,w ≤ C`.
1
√ √
• α= 2
⇒w= `, h = `,
• α = 1 ⇒ w = 1, h = `,
1
bh,w ≤ C` 2 log ` .
For the study of bhw for general values of α, we replace inequality (5.2)
α2
bhw < C`(1−α)(α log `+2)+ 2
log `
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
¡ ¢
Figure 5.4: The parabola f (α) = α 1 − α2 for 0 ≤ α ≤ 1.
See Figure 5.4 for the behavior of the coefficient of log ` in the exponent
of equation (5.3).
¡ ¢
Proof: For ` ≥ 6, the expression α 1 − α2 log ` + 2(1 − α) has a positive
derivative for 0 ≤ α ≤ 1. Thus, the right side of inequality (5.3) gets its
Proposition 5.5.4 For small values of h, such that log h ¿ log `, the lower
bound is of order of magnitude ∼ `log h+1 .
¡`¢
Proof: Substituting w = h
, in Proposition 5.5.2 yields the following lower
77
bound:
µ ¶dlog he+1
` 1
bhw ≤ C h 2 log h
h
1
= C`dlog he+1 · h 2 log h−(dlog he+1)
log2 h−(dlog he+1)·log h
= C`dlog he+1+ log `
≈ C`log h+1 .
5.5.3 Algorithm
M at
It is not hard to see that P (Hhw , Cij ) gets its maximal value for i = d h2 e,
M at
1 ≤ j ≤ w. So applying Algorithm 5.2 to Hhw yields Algorithm 5.4.
M at
Algorithm 5.4 M oveM at (Hhw , S, D)
1: if h = 0 then
2: transfer one block from S to D.
3: else
4: for i ← 1 to w do
5: M oveM at (H(0,0),(d h e,i) , S, v(d h e,i)1 ).
2 2
6: end for
M at
S
w
7: M oveM at (Hhw \{ Cd h e,i }, S, D).
2
i=1
8: for i ← w downto 1 do
9: M oveM at (H(d h e,i),(h+1,1) , v(d h e,i)1 , D).
2 2
10: end for
11: end if
M at
Denoting the number of blocks Algorithm 5.4 transfers in Hhw from S
We can use the technique used in Theorem 3.2.1 (2) with slight modifi-
mat
Given a Matrix graph Hhw , we get from Lemma 5.5.1 a lower bound on the
n
number of moves required to solve HAN (H, n) i.e. Ω` (2 bhw ). On the other
n
hand we introduced a block-algorithm solving the problem with O` (2 chw )
steps. We show in this section that bhw and chw , are in fact, very close to
each other.
bhw
Proposition 5.5.7 For each h ≥ 0, cbw
≤ 2 · 3dlog he < 6 · hlog 3 .
b0w
Proof: For h = 0, b0w = 2, whereas c0w = 1. So, c0w
= 2 = 2 · 30 .
For h ≥ 1,
We note that 6·hlog 3 < 6·h1.6 . That is, the ratio is a low degree polynomial
and bhw .
Bibliography
[2] J.P. Allouche and F. Dress, Tours de Hano et automates., Inform. Theor.
Appl, 24 (1990), 1–15.
[3] J.P. Allouche and A. Sapir, Restricted towers of Hanoi and morphisms,
Developments in Language Theory, Lecture Notes in Comput. Sci., vol.
3572, Springer, Berlin, 2005, pp. 1–10.
[4] M.D. Atkinson, The cyclic towers of Hanoi, Inform. Process. Lett. 13
(1981), 118–119.
[5] D. Azriel, Two questions on the Hanoi tower problem over directed
graphs, Master’s thesis, Dept. of Mathematics and Computer Science,
BenGurion University, 2006, Advisor: D. Berend.
79
80
[9] D. Berend and A. Sapir, The cyclic multi-peg tower of Hanoi, ACM
Trans. Algorithms 2 (2006), 297–317.
[10] J-P. Bode and A.M. Hinz, Results and open problems on the Tower
of Hanoi, Congr. Numer. 139 (1999), 113–122, Proc.30th Southeastern
Internat. Conf. on Combinatorics, Graph Theory, and Computing (Boca
Raton, FL, 1999).
[11] P. Buneman and L. Levy, The towers of Hanoi problem, Inform. Process.
Lett. 10 (1980), 243–244.
[12] T-H. Chan, A statistical analysis of the towers of Hanoi problem, Intern.
J. Computer Math. 28 (1989), 57–65.
[13] X. Chen and J. Shen, On the Frame–Stewart Conjecture about the Tow-
ers of Hanoi., SIAM J. Comput. 33 (2004), no. 3, 584–589.
[14] D.W. Crowe, The n-dimensional cube and the tower of Hanoi, Amer.
Math. Monthly 63 (1956), 29–30.
[15] Y. Dinitz and S. Solomon, Optimal Algorithms for Tower of Hanoi Prob-
lems with Relaxed Placement Rules., The 17th International Symposium
on Algorithms and Computation (2006), 36–47.
[16] H.E. Dudeney, The Canterbury Puzzles and Other Curious Problems,
4th ed., Dover, Mineola, NY, 1958, 1st edn: W. Heinemann, 1907.
[17] Dunkan, Editorial note the solution of problem 3918, Amer. Math.
Monthly 48 (1941), 219.
81
[19] M.C. Er, The complexity of the generalized cyclic towers of Hanoi prob-
lem, J. Algorithms 6 (1985), 351–358.
[20] M.C. Er, A general algorithm for finding a shortest path between two
n-configurations, Inf. Sci. 42 (1987), 137–141.
[23] A.M. Hinz, The tower of Hanoi, Enseign. Math. 35 (1989), 289–321.
[24] A.M. Hinz, Pascal’s triangle and the tower of Hanoi, Amer. Math.
Monthly 99 (1992), 538–544.
[26] C.S. Klein and S. Minsker, The super towers of Hanoi problem: large
rings on small rings, Discrete Math. 114 (1993), 283–295.
[27] R.E. Korf., Best-First frontier search with delayed duplicate detection.,
Proc. of National Conf. on AI (AAAI-04), 2004, pp. 650–657.
82
[28] R.E. Korf and A. Felner, Recent Progress in Heuristic Search: A Case
Study of the Four-Peg Towers of Hanoi Problem., IJCAI, 2007, pp. 2324–
2329.
[30] E. Leiss, Finite Hanoi problems: how many discs can be handled?, Pro-
ceedings of the 15th Southeastern Conf. on Combinatorics, Graph The-
ory and Computing (Baton Rouge, La., 1984), vol. 44, 1984, pp. 221–
229.
[35] J.S. Rohl, Towers of Hanoi: The Derivation of Some Iterative Versions.,
Comput, J. 30 (1987), no. 1, 70–76.
[36] D. Romik, Shortest paths in the Tower of Hanoi graph and finite au-
tomata., SIAM J. Disc. Math. 20 (2006), 610–622.
[39] B.M. Stewart, Problem 3918 (k-peg tower of Hanoi), Amer. Math.
Monthly 46 (1939), 363, solution by J. S. Frame, ibid. 48 (1941) 216–
217; ibid. 217–219.
[42] M. Szegedy, In how many steps the k peg version of the towers of Hanoi
game can be solved?, STACS 99, Trier, Lecture Notes in Computer Sci-
ence, vol. 1563, Springer, Berlin, 1999, pp. 356–361.
[43] D. Wood, The towers of Brahma and Hanoi revisited, J. Recr. Math. 14
(1981), 17–24.