LAMC Junior Circle January 22, Oleg Gleizer. The Hanoi Tower. Part 2

Similar documents
= (2 3 ) = c LAMC Beginners Circle September 29, Oleg Gleizer. Warm-up

Finite Math - Fall 2016

Lesson Plan for Teachers

LAMC Junior Circle February 3, Oleg Gleizer. Warm-up

COUNTING AND PROBABILITY

1111: Linear Algebra I

Permutations and Combinations Problems

CS 32 Puzzles, Games & Algorithms Fall 2013

Section 8.1. Sequences and Series

Games of Skill ANSWERS Lesson 1 of 9, work in pairs

Coding Theory on the Generalized Towers of Hanoi

Permutations and Combinations

Tree Diagrams and the Fundamental Counting Principle

Elementary Combinatorics

Permutations and Combinations

Enumerative Combinatoric Algorithms. Gray code

MATH 2420 Discrete Mathematics Lecture notes

Games of Skill Lesson 1 of 9, work in pairs

Let start by revisiting the standard (recursive) version of the Hanoi towers problem. Figure 1: Initial position of the Hanoi towers.

LAMC Beginners Circle April 27, Oleg Gleizer. Warm-up

Number Theory - Divisibility Number Theory - Congruences. Number Theory. June 23, Number Theory

Concept: The Meaning of Whole Numbers

ECS 20 (Spring 2013) Phillip Rogaway Lecture 1

PERMUTATIONS - II JUNIOR CIRCLE 11/17/2013

17. Symmetries. Thus, the example above corresponds to the matrix: We shall now look at how permutations relate to trees.


Exercise 2. Match. 2-2 Count Things Up to 5

Midterm Examination. CSCI 561: Artificial Intelligence

Module 7 Solving Complex Problems

A light year is 5.9 x miles. Kronos wants to travel from Rigel Kentaurus to Earth. This is the distance light travels in one year.

MATH MILESTONE # A5 DIVISION

Binary Continued! November 27, 2013

First Group Second Group Third Group How to determine the next How to determine the next How to determine the next number in the sequence:

LAMC Intermediate I & II December 14, Oleg Gleizer. Math Wrangle

MA10103: Foundation Mathematics I. Lecture Notes Week 3

CRACKING THE 15 PUZZLE - PART 2: MORE ON PERMUTATIONS AND TAXICAB GEOMETRY

Place Value, Fractions & Decimals

How Many Mates Can a Latin Square Have?

Permutations. describes the permutation which sends 1! 2, 2! 1, 3! 3.

Section Summary. Permutations Combinations Combinatorial Proofs

Week 1: Probability models and counting

ENGR170 Assignment Problem Solving with Recursion Dr Michael M. Marefat

CALCULATING SQUARE ROOTS BY HAND By James D. Nickel

An Efficient Implementation of Tower of Hanoi using Gray Codes

COLLEGE ALGEBRA. Arithmetic & Geometric Sequences

ALGEBRA: Chapter I: QUESTION BANK

John H. Conway, Richard Esterle Princeton University, Artist.

PERMUTATIONS - II JUNIOR CIRCLE 05/01/2011

Module 7 Solving Complex Problems

Contents. Introduction Place Value up to Billions... 6 Powers and Exponents... 9 Place Value... 12

Mathematical Foundations of Computer Science Lecture Outline August 30, 2018

The Apprentices Tower of Hanoi

Week 1. 1 What Is Combinatorics?

Compressing Pattern Databases

English Version. Instructions: Team Contest

TOPIC 2: HOW TO COUNT

Sec$on Summary. Permutations Combinations Combinatorial Proofs

JUST THE MATHS UNIT NUMBER PROBABILITY 2 (Permutations and combinations) A.J.Hobson

1. The sides of a cube are increased by 100%. By how many percent 1. percent does the volume of the cube increase?

lecture notes September 2, Batcher s Algorithm

Probability. Engr. Jeffrey T. Dellosa.

1.6 Congruence Modulo m

Mathematics Competition Practice Session 6. Hagerstown Community College: STEM Club November 20, :00 pm - 1:00 pm STC-170

METHOD 1: METHOD 2: 4D METHOD 1: METHOD 2:

Extended Introduction to Computer Science CS1001.py

Problem Solving Problems for Group 1(Due by EOC Sep. 13)

of Nebraska - Lincoln

How to Calculate the Probabilities of Winning the Nine Cash4Life Prize Levels:

Factors and Products. Jamie is 12 years old. Her cousin, 6 Prime Time

Counting Snakes, Differentiating the Tangent Function, and Investigating the Bernoulli-Euler Triangle by Harold Reiter

Theory of Probability - Brett Bernstein

Magnetic Towers of Hanoi and their Optimal Solutions

Three Pile Nim with Move Blocking. Arthur Holshouser. Harold Reiter.

2014 MATH Olympiad [Grade1]

6.2 Modular Arithmetic

NUMBER THEORY AMIN WITNO

PUZZLES ON GRAPHS: THE TOWERS OF HANOI, THE SPIN-OUT PUZZLE, AND THE COMBINATION PUZZLE

SELECTED GEOMETRICAL CONSTRUCTIONS

MTEL General Curriculum Mathematics 03 Multiple Choice Practice Test B Debra K. Borkovitz, Wheelock College

2009 Philippine Elementary Mathematics International Contest Page 1

Combinatorics. Chapter Permutations. Counting Problems

2014 MATHOlympiad [Grade

UK Junior Mathematical Challenge

An Optimal Algorithm for a Strategy Game

Computer Science Scholarship Puzzle Packet

Sec. 4.2: Introducing Permutations and Factorial notation

Lesson 1: Place Value of Whole Numbers. Place Value, Value, and Reading Numbers in the Billions

How to Calculate the Probabilities of Winning the Nine Mega Millions Prize Levels:

Free GK Alerts- JOIN OnlineGK to NUMBERS IMPORTANT FACTS AND FORMULA

A Group-theoretic Approach to Human Solving Strategies in Sudoku

1. Answer (B): Brianna is half as old as Aunt Anna, so Brianna is 21 years old. Caitlin is 5 years younger than Brianna, so Caitlin is 16 years old.

Sets, Venn Diagrams & Counting

aabb abab abba baab baba bbaa permutations of these. But, there is a lot of duplicity in this list, each distinct word (such as 6! 3!2!1!

1 = 3 2 = 3 ( ) = = = 33( ) 98 = = =

Puzzling Math, Part 2: The Tower of Hanoi & the End of the World!

Team Round University of South Carolina Math Contest, 2018

Permutations and Combinations. MATH 107: Finite Mathematics University of Louisville. March 3, 2014

Introduction to Fractions

Discrete Mathematics: Logic. Discrete Mathematics: Lecture 15: Counting

39 th JUNIOR HIGH SCHOOL MATHEMATICS CONTEST APRIL 29, 2015

Transcription:

LAMC Junior Circle January 22, 2012 Oleg Gleizer The Hanoi Tower Part 2 Definition 1 An algorithm is a finite set of clear instructions to solve a problem. An algorithm is called optimal, if the solution it provides is the shortest possible. In this class, we shall find an optimal algorithm that solves the Hanoi tower puzzle. Consider the original arrangement with all the disks on the left rod. Let us number the disks 1 through n from the top to the bottom. Let us name the rods A, B, and C from the left to the right. Let us write down the moves in three-symbol words, first the number of the disk, then the name of the rod it is moved from, and finally the name of the rod the disk is moved to. For example, the move that shifts the second disk from rod A to rod C will be denoted as 2AC. Problem 1 Using the above notations, write down the following move: disk five from rod B to rod C. Let us first solve the Hanoi tower puzzle with two disks. In this case, it s easy to figure out the algorithm: the first disk goes 1

from rod A to rod B, then the second disk is moved from rod A to rod C, and finally the first disk goes from rod B to rod C. Let us call the algorithm HT 2 (AC). In the above notations, it can be written down as follows. HT 2 (AC) = 1AB 2AC 1BC (1) HT 2 (AC) not only solves the Hanoi tower puzzle with two disks, but also does it the shortest possible way and thus is optimal. (Why?) Problem 2 Write down the shortest algorithm, HT 2 (AB), that moves two disks from rod A to rod B. Note that the formula you get is nothing but formula 1 with letters B and C switched. Problem 3 Rewrite formula 1 with letters A and B switched. Write down the optimal algorithm, HT 2 (BC), that moves two disks from rod B to rod C. Do you get the same formula? Why? 2

Let us consider the three-disk case. To move the third disk from rod A to rod C, we first need to move the upper two disks from rod A to rod B. This is done by the algorithm HT 2 (AB) from Problem 2. Further on, the move 3AC shifts the third disk from rod A to rod C. Finally, we need to move the first two disks from rod B to rod C. The algorithm doing just that, HT 2 (BC), is found in Problem 3. So here comes the algorithm for three disks: HT 3 (AC) = HT 2 (AB) 3AC HT 2 (BC) (2) or explicitly, HT 3 (AC) = 1AC 2AB 1CB 3AC 1BA 2BC 1AC (3) Problem 4 Use the actual puzzle to check if the above algorithm really works for three disks. Problem 5 Is the algorithm HT 3 (AC) optimal? Why or why not? Let us call the number of moves needed to solve the puzzle with n disks N(n). Then N(2) = 3 and N(3) = N(2) + 1 + N(2) = 3 + 1 + 3 = 7. Problem 6 Write down the optimal algorithm, HT 3 (BC), that moves three disks from rod B to rod C. Problem 7 Write down the optimal algorithm, HT 3 (AB), that moves three disks from rod A to rod B. 3

Problem 8 Using Problems 6 and 7 combined, write down the optimal algorithm, HT 4 (AC), that moves four disk from rod A to rod C. To see whether it really works, apply the algorithm to the actual puzzle. Problem 9 Find N(4). Problem 10 Write down the optimal algorithm that solves the puzzle for n = 5. Apply the algorithm to the actual puzzle. Find N(5). It s time to generalize: once we know the optimal algorithm HT n (AC) to move n disks from rod A to rod C, we can construct 4

the algorithm HT n+1 (AC) optimal for solving the puzzle with n + 1 disks. HT n (AB), the algorithm obtained from HT n (AC) by switching letters B and C in every three-symbol word, moves the top n disks from rod A to rod B. The next move, (n+1)ac, shifts the largest disk from rod A to rod C. Finally, the algorithm HT n (BC), that is HT n (AC) with letters A and B replacing each other, moves the upper n disks from rod B to rod C. HT n+1 (AC) = HT n (AB) (n + 1)AC HT n (BC) (4) HT n+1 (AC) is optimal as well. (Why?) Its length Problem 11 Find N(10). N(n + 1) = N(n) + 1 + N(n) (5) HT n is an example of a recursive algorithm. In order to solve the puzzle with n disks, we need to apply our solution procedure to the problem with n 1 disks. HT n (AC) = HT n 1 (AB) nac HT n 1 (BC) 5

To solve the latter, we run the algorithm for n 2 disks, HT n (AC) = HT n 2 (AC) (n 1)AB HT n 2 (CB) }{{} HT n 1 (AB) nac HT n 2 (BA) (n 1)BC HT n 2 (AC) }{{} HT n 1 (BC) and so forth. Problem 12 Find the optimal algorithm to solve the Hanoi tower puzzle with eight disks having the following initial arrangement: the eighth disk is on rod B, the seventh on rod A, the first six disks on rod C. How many moves will it take? 6

Consider the Hanoi tower puzzle with four rods (also known as Reve s puzzle). We can easily come with the following winning algorithm for n disks. Choose 0 < k < n. Use the optimal algorithm for three rods and k disks to move the first k disks to any rod except for the last one. Keeping the first k disks still, move the remaining n k disks to the last rod by using the optimal algorithm for three rods and n k disks. The problem is reduced to a similar one, but with k disks instead of n. For any k = 1, 2,..., n 1, the algorithm solves the puzzle, but is any of the above n 1 algorithms optimal? We don t know! The problem of finding an optimal solution for the Hanoi tower puzzle with more than three rods is still open. Quite often, a path from an elementary school problem to the frontier of the ongoing research is not too long. Problem 13 Using a pencil as the forth rod, solve the Hanoi tower puzzle with four rods and five disks. Suppose that the monks move a disk every second. Using formula 5, it is not too hard to find N(64). The computation shows that the monks will need more than 500, 000, 000, 000 years, that is five hundred billion years, to solve the puzzle. Our world will not end in quite some time! 7