On optimal solutions for the bottleneck tower of hanoi problem
Download
1 / 74

On Optimal Solutions for the Bottleneck Tower of Hanoi Problem - PowerPoint PPT Presentation


  • 234 Views
  • Uploaded on

On Optimal Solutions for the Bottleneck Tower of Hanoi Problem . Yefim Dinitz Shay Solomon Dept. of Comp. Sci., Ben-Gurion University ISRAEL. Contents of the lecture. 1. Background on the Tower of Hanoi. 2. The Bottleneck Tower of Hanoi (BTH) problem.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'On Optimal Solutions for the Bottleneck Tower of Hanoi Problem' - fergal


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
On optimal solutions for the bottleneck tower of hanoi problem l.jpg

On Optimal Solutions for the Bottleneck Tower of Hanoi Problem

Yefim Dinitz Shay Solomon

Dept. of Comp. Sci., Ben-Gurion University

ISRAEL


Contents of the lecture l.jpg
Contents of the lecture Problem

1. Background on the Tower of Hanoi.

2. The Bottleneck Tower of Hanoi (BTH) problem.

3. The family of all optimal solutions to BTH.

4. Investigation of the configuration graph of

BTH: its diameter and average distance.


1 background l.jpg
1. Background Problem

  • The first version of the puzzle was marketed by Edouard Lucas in 1883, under the name "Tower of Hanoi“:

    - Given are 3 pegs, denoted by A,B and C, and ndisks of distinct sizes placed on peg A in decreasing order, largest at the bottom to the smallest at the top.

    - The goal of the puzzle is to transfer all disksto peg C, placed in the same order, by the minimum possible number of moves.

    - The rules are to move a single disk from (the top of) one peg to (the top of) another one at each step, following the "divine rule": to never have a larger disk above a smaller one.


Slide4 l.jpg

Move number Problem

Example for general n

1

2

n-1

n

A B C


Slide5 l.jpg

Move number Problem

Cn-1

The optimal transfer for general n

1

2

n-1

n

A B C


Slide6 l.jpg

Move number Problem

Cn-1 + 1

The optimal transfer for general n

1

2

n-1

n

A B C


Slide7 l.jpg

Move number Problem

2 Cn-1 + 1

The optimal transfer for general n

1

2

n-1

n

A B C


Slide8 l.jpg

The Problem recurrence formula is

cn = 2cn-1 + 1, c1 = 1.

Hence,cn = 2^n -1.

This classical Tower of Hanoi problem with three pegs is a basic problem, taught as a basic example of a recursion program.


There is a great proliferation of new toh puzzles posed over the last twenty years l.jpg

There is a great proliferation of Problem new ToH puzzles posed over the last twenty years.

There is a bibliography made by Paul Stockmeyer, which covers over 350

papers on the subject.


Slide10 l.jpg

2. The Bottleneck ToH problem Problem

In 1981, D. Wood posed the following generalization of ToH, which we call the

“Bottleneck Tower of Hanoi Problem, BTHn= BTHn,k”,

depending on an integer parameter k, k>0.


Slide11 l.jpg

The k-relaxed Placement Rule: Problem Besides the usual placement of smaller disks above bigger ones, a bigger disk j may be placed above a smaller disk i, if their size difference j - i < k.

i+k

….

….

i


Slide12 l.jpg

Definitions Problem

  • A placement of the n disks [1..n] on a single peg is called a tower of n disks.

  • The decreasing bottom-top placement of the n disks [1..n] on a peg is called the perfect tower.

1

2

3

n-2

n-1

n


Description of bth n l.jpg
Description of Problem BTHn:

  • There are 3 pegs: A,B, and C.

  • The goal is to transfer the perfect toweron peg A to the perfect toweron peg C.

  • The placement rule is k-relaxed.

    (Note that if k=1, we arrive at the classical problem.)


Slide14 l.jpg

Example: Problem k=4, n=7

We note that there are many legal towers for a given k.

As k grows, there are morelegal towers.

1

2

3

7

6

5

4

(The two extreme) examples:

k=1, one legal tower (perfect tower).

k≥n, n!possible towers.

Legal


Slide15 l.jpg

  • D.Poole [1992] suggested the sequence of moves Problem αn (described in the next slide), which solves BTHn. He showed its optimality within just one simple strategy.

  • Beneditkis, Berend, and Safro[1998]proved its optimalityfor the case k=2.

  • We proved optimality of αn for the general case [ISAAC’2006].

  • Remark: another proof of optimality ofαn for BTHn, by different techniques, was suggested independently by Xiaomin Chen et al. (unpublished).


N a c not explicitly l.jpg
α Problem n(A,C) (not explicitly)

1.(*) Move disks [1..(n-1)] from A,

by the minimum possible number of moves, to any (legal) state on B.

2. Move disk n from A to C.

3.(*) Move disks [1..(n-1)] from B to the perfect tower on C, by the minimum possible number of moves.


Slide17 l.jpg

1 Problem

2

3

4

….

….

….

….

….

n-1

n

B

C

A


Slide18 l.jpg

[1..n-1] Problem

n

B

C

A


Slide19 l.jpg

[1..n-1] Problem

n

B

C

A


Slide20 l.jpg

1 Problem

2

3

4

….

….

….

….

….

n-1

n

B

C

A


Slide21 l.jpg
“Somehow” tower-move(*) Problem :To move a tower of m disks on one peg, to a tower of m disks on another peg, in anyorder.

  • D. Poole and BBS used, for the “somehow” problem, the following optimal sequence of moves, βm:


M source target for the explanation assume that the initial configuration is perfect l.jpg
β Problem m(source,target):(for the explanation, assume that the initial configuration is perfect)

  • If m ≤ k, move all disks from source to target one by one.

  • Otherwise:

    1.Recursively perform βm-k(source,auxiliary).

    2. Move k disks [(m-k+1)..m] one by one fromsource to target.

    3. Recursively perform βm-k(auxiliary,target).


Slide23 l.jpg

K=4, m=7 Problem

1

2

3

4

5

6

7

source auxiliary target


Slide24 l.jpg

4 Problem

5

6

7

3

2

1

source auxiliary target


Slide25 l.jpg

7 Problem

6

5

4

3

2

1

source auxiliary target


Slide26 l.jpg

1 Problem

2

3

7

6

5

4

source auxiliary target


Slide27 l.jpg

K=4, m=11 Problem

1

2

3

4

5

6

7

8

9

10

11

source auxiliary target


Slide28 l.jpg

8 Problem

9

10

11

1

2

3

7

6

5

4

source auxiliary target


Slide29 l.jpg

11 Problem

10

9

8

1

2

3

7

6

5

4

source auxiliary target


Slide30 l.jpg

1 Problem

2

3

4

5

6

7

11

10

9

8

source auxiliary target


Slide31 l.jpg

(**) We remark that, if we start with the Problem perfect tower on A, and perform βm(A,B)followed byβm(B,C), the result is the perfect tower on C.


N a c reformulated l.jpg
α Problem n(A,C), reformulated

1. perform βn-1(A,B).

2. Move disk n from A to C.

3. perform βn-1(B,C).

By earlier remark (**), αnsolves BTHn.


Slide33 l.jpg

1 Problem

2

3

4

….

….

….

….

….

n-1

n

B

C

A


Slide34 l.jpg

1 Problem

2

3

….

….

n-k-1

n-1

….

n-k+1

n-k

n

B

C

A


Slide35 l.jpg

1 Problem

2

3

….

….

n-k-1

n-1

….

n-k+1

n-k

n

B

C

A


Slide36 l.jpg

1 Problem

2

3

4

….

….

….

….

….

n-1

n

B

C

A


Notation and numerical results l.jpg
Notation and numerical results Problem

  • bm = The number of moves in βm

  • an = The number of moves in αn

  • bm = 2bm-k + k ; b1 = 1,…, bk = k.

    bm = r (2^q) + k (2^q -1),

    where m = qk +r.

  • an = 2bn-1 + 1 ; a1 = 1.

    an = r (2^(q+1)) + k (2^(q+1) -2) + 1,

    where n-1=qk + r.


3 family of all optimal solutions to bth n l.jpg
3. Family of all optimal solutions to Problem BTHn

We provethat, in any optimal solution toBTHn, disk n makes only one move, from peg A to C.

Before that move, all disks 1,…,n-1 have been moved from peg A to peg B.

After that move, all disks 1,..,n-1 willmove from peg B to peg C.


Slide39 l.jpg

Is Problem αn the unique optimal solution?

In the casek=1, the answer is yes (and is well known): there exists a unique solution for the classical problem.

For the case k ≥ 2, the answer is

No!

Let us see a different sequence of moves, of the same length as that of αn:


Slide40 l.jpg

Example n=10, k=3 Problem

1

2

3

4

5

6

7

8

9

10

A B C


Slide41 l.jpg

4 Problem

5

6

7

8

9

10

3

2

1

A B C


Slide42 l.jpg

7 Problem

8

9

10

3

2

1

6

5

4

A B C


Slide43 l.jpg

1 Problem

2

3

6

5

4

7

8

9

10

A B C


Slide44 l.jpg

1 Problem

2

3

6

5

4

9

8

7

10

A B C


Slide45 l.jpg

Until this point, the move-sequence is the same as Problem αn

6

5

4

3

2

1

10

9

8

7

A B C


Slide46 l.jpg

5 Problem

4

3

6

9

8

7

2

1

10

A B C


Slide47 l.jpg

2 Problem

5

3

6

9

8

7

4

1

10

A B C


Slide48 l.jpg

1 Problem

4

2

5

3

6

9

8

7

10

A B C


Slide49 l.jpg

1 Problem

4

2

5

3

6

9

8

7

10

A B C


Slide50 l.jpg

9 Problem

8

7

3

2

1

10

6

5

4

A B C


Slide51 l.jpg

9 Problem

8

7

1

2

3

6

5

4

10

A B C


Slide52 l.jpg

1 Problem

2

3

6

5

4

7

8

9

10

A B C


Slide53 l.jpg

6 Problem

5

4

7

8

9

10

3

2

1

A B C


Slide54 l.jpg

4 Problem

5

6

7

8

9

10

3

2

1

A B C


Slide55 l.jpg

1 Problem

2

3

4

5

6

7

8

9

10

A B C


Tower move l.jpg
Tower-Move Problem

  • tower-move – A sequence of moves that transfers a tower on one peg to a tower on another peg.

  • For example:

    - αnis a shortest perfect-to-perfect tower-move of n disks.

    - βmis a shortest “somehow” tower-move

    of m disks.


General structure of an optimal tower move l.jpg
General structure of an optimal tower-move Problem

  • It should be similar to the structure of the (recursive) classic Tower of Hanoi solution, but the transfer unit is a block of k disks (as in the example).

  • Main Proposition 1: The only possible change, in an optimal solution, may be to interleave the two upper blocks.

  • Main Observation 2: The ways of interleaving, each time, are independent.


Slide58 l.jpg

How many optimal solutions exist? Problem

  • Any optimal solution (i.e., a shortest p.t.p. tower move of [1..n]) contains 2^(┌(n-1)/k┐-1) tower-moves of the union of the two upper blocks.

  • For any such even-numbered tower-move, except for the last tower-move, its final configuration can be chosen arbitrarily from a certainset (**) ofC(k+r,k)-C(k+r,k+1)configurations.

  • These are the only choices, for an optimal solution.


Slide59 l.jpg

An auxiliary problem Problem equivalent to (**):Let n ≤ t+p.What is the number of integer solutions that satisfy the two following conditions:

How many such configurations exist?

  • ∑xi =n, i=[0..t], xi≥0.

  • ∑xi ≤ j+p, 0≤j ≤n-p, i=[0..j].


Slide60 l.jpg

The number of different solutions to (**) is: Problem

C(n+t,t) – C(n+t,t+p+1)


The number of all optimal solutions to bth n is l.jpg

The number of all optimal solutions Problem toBTHn is:

k=1:

A unique optimal solution

k ≥ 2:

(C(k+r,k)-C(k+r,k+1))^[┌2^(┌(n-1)/k┐-2)┐-1],

where r= (n-1) mod k.


4 1 diameter of the configuration graph l.jpg
4.1 Diameter of the configuration graph Problem

Questions :

1. Find a pair of disk arrangements over A,B and C, requiring the longest sequence of moves in order to get from one to the other.

2. Find the length of that sequence (later referred as “diameter”).

Let us translate these questions to the language of graphs:


Slide63 l.jpg

  • For Problem BTHn , the corresponding configuration graph, G=(V,E) is the (undirected) graph s.t.:

  • V is the set of all legal arrangements of the n disks over A, B and C.

  • E = {e=(u,v)| u,v in V, s.t. u and v are reachable one from the other by a single move}.


Slide64 l.jpg

The configuration graph for the case Problem n=2,k=2

(),(2),(1)

(),(2,1),()

(),(),(1,2)

(1,2),(),()

(2),(),(1)

(2,1),(),()

(),(),(2,1)

(2),(1),()

(1),(),(2)

(),(1),(2)

(),(1,2),()

(1),(2),()


Slide65 l.jpg

The diameter is 4 Problem

(),(2),(1)

(),(2,1),()

(),(),(1,2)

(1,2),(),()

(2),(),(1)

(2,1),(),()

(),(),(2,1)

(2),(1),()

(1),(),(2)

(),(1),(2)

(),(1,2),()

(1),(2),()


We found the answer for the second question i e the diameter d n k up to a constant factor l.jpg

We found the answer for the second question, i.e. the diameter, D(n,k),up to a constant factor.

D(n,k) =Θ((k^2)∙2^(n/k))

This is k times the shortest length of

a perfect-to-perfect tower-move.

Reminder: an = Θ(k ∙2^(n/k))


Tighter bounds for d n k l.jpg
Tighter bounds for D(n,k): diameter,

  • Let n ≤ k

    D(n,k) = Θ(n∙logn).

  • Let k ≤ n ≤ 2k

    D(n,k) = Θ(n∙logn + (n-k)^2).

  • For n>2k:

    D(n,k) = Θ((k^2)∙2^(n/k)).


Slide68 l.jpg

We believe (based on similar open questions raised by D. Knuth) that both afore-mentioned questions:

1. Finding a pair of disk arrangements requiring a longest sequence of moves.

2. Finding the length of that sequence (i.e, the previously mentioned diameter) exactly.

should be difficult even for the (degenerate) case n≤k.


4 2 average distance l.jpg
4.2 Average distance Knuth) that both afore-mentioned questions:

We find the average number of moves required to get from one configuration to another, taken over all pairs of configurations, up to a constant factor.

In other words, we bound the average distance between nodes in the configuration graph of BTHn.


We prove that the average avg n k is asymptotically the same as the afore mentioned diameter l.jpg

We prove that the average Knuth) that both afore-mentioned questions:,Avg(n,k), is asymptotically the same as the afore-mentioned diameter.

For n ≥ 3k:

Avg(n,k) = Θ(D(n,k)) =Θ((k^2)∙2^(n/k))

This is k times the shortest length of a

p.t.p. tower-move.


Avg n k for some values of n vs k l.jpg
Avg(n,k) for some values Knuth) that both afore-mentioned questions: of n vs. k:

  • Let n ≤ k:

    Avg(n,k) = Θ(D(n,k)) = Θ(nlogn).

  • For n>3k:

    Avg(n,k) = Θ(D(n,k)) = Θ((k^2)∙2^(n/k)).


Slide72 l.jpg

In our paper at ISAAC’06, we considered optimal algorithms for ToH problems with generalized placement rules.

We appreciate your attention.


The w ay of proof for diameter l.jpg
The for ToH problems with generalized placement rules.way of proof (for diameter)

Upper bound: We show an explicit way to transfer any tower of n disks in O((k^2)∙2^(n/k)) moves.


Lower bound l.jpg
Lower bound for ToH problems with generalized placement rules.

  • Observation. When any disk out of the k biggest disks [(n-k+1)..n] moves, alln-2kdisksin [1..(n-2k)] should be on the spare peg.

  • We show two configurations of the k biggest disks, such that any tower-move between them requires Ω(k)changes of the spare peg.

  • As a consequence, for those configurations and the case n>2k, Ω(k) tower-moves of the n-2k smallest disks are required.

    As we know, each one of those tower-moves requires Ω(k∙2^((n-2k)/k))moves.


ad