When Will The World End “Temple of Brahma” legend from the Indian city of Benares Priests must move 64 gold disks from one end of the temple to the other.

Slides:



Advertisements
Similar presentations
Tower of Hanoi Tower of Hanoi is a mathematical puzzle invented by a French Mathematician Edouard Lucas in The game starts by having few discs stacked.
Advertisements

The Towers of Hanoi or Apocalypse When?.
By Katie Dzerovych Jon Wood JB Henderson Mentor Professor Snapp.
The Tower Of Hanoi Edouard Lucas
Chapter Recurrence Relations
More Recursion: Permutations and Towers of Hanoi COP 3502.
Analyzing Algorithms and Problems Prof. Sin-Min Lee Department of Computer Science.
Recurrences. What is a Recurrence Relation? A system of equations giving the value of a function from numbers to numbers in terms of the value of the.
The Tower of Hanoi Ben Epstein Special Topics 2003.
Recursion.
Recursion!. Question Stephen King’s books J. R. R. Tolkien’s books Recursion Do they have something in common?
Review of Recursion. Definition: Recursion - The process of a function calling itself.
The Tower of Hanoi
1 Section 6.1 Recurrence Relations. 2 Recursive definition of a sequence Specify one or more initial terms Specify rule for obtaining subsequent terms.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 16: Recursion.
RECURSIVE PATTERNS WRITE A START VALUE… THEN WRITE THE PATTERN USING THE WORDS NOW AND NEXT: NEXT = NOW _________.
Stacks CSE, POSTECH. 2 2 Stacks Linear list One end is called top. Other end is called bottom. Additions to and removals from the top end only.
Chapter 8 With Question/Answer Animations 1. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Introduction to Programming (in C++) Recursion Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC.
Copyright © Cengage Learning. All rights reserved.
Recursively Defined Sequences Lecture 35 Section 8.1 Wed, Mar 23, 2005.
Advanced Counting Techniques
Analysis of Algorithm Lecture 3 Recurrence, control structure and few examples (Part 1) Huma Ayub (Assistant Professor) Department of Software Engineering.
25-2 Recursive Functions Related Chapter: ABC 5.14, 5.15.
Data Structures: A Pseudocode Approach with C1 Chapter 2 Objectives Upon completion you will be able to: Explain the difference between iteration and recursion.
13.2 Recursive Definitions Objective 1) Provide the recursive definition for sequences; 2) Identify the type of a sequence from a recursive definition.
Recursion Jordi Cortadella Department of Computer Science.
# 1# 1 VBA Recursion What is the “base case”? What is the programming stack? CS 105 Spring 2010.
Recursion. Hanoi Tower Legend: Inside a Vietnamese temple there are three rods (labeled as r 1, r 2, and r 3 ), surrounded by n golden disks of different.
Whiteboardmaths.com © 2004 All rights reserved
Java Programming: Guided Learning with Early Objects Chapter 11 Recursion.
Upon completion, the world will end…
Chapter 6.1: Recurrence Relations Discrete Mathematical Structures: Theory and Applications.
 STACK STACK  STACK OPERATIONS STACK OPERATIONS  PUSH ALGORITHM PUSH ALGORITHM  POP ALGORITHM POP ALGORITHM  USES OF STACK USES OF STACK  THE TOWER.
22C:19 Discrete Math Advanced Counting Fall 2010 Sukumar Ghosh.
Recursion Colin Capham Recursion – an introduction to the concept.
Review of Recursion  a recursive method calls itself  to prevent infinite recursion you need to ensure that: 1. the method reaches a base case 2. each.
UNIT 17 Recursion: Towers of Hanoi.
Recursion Chapter What is recursion? Recursion occurs when a method calls itself, either directly or indirectly. Used to solve difficult, repetitive.
1 In this puzzle, the player begins with n disks of decreasing diameter placed one on top of the other on one of three pegs of the game board. The player.
Tower of Hanoi Tower of Hanoi is a mathematical puzzle invented by a French Mathematician Edouard Lucas in The game starts by having few discs stacked.
Recursively Defined Sequences Lecture 40 Section 8.1 Wed, Apr 11, 2007.
Recursion by Ender Ozcan. Recursion in computing Recursion in computer programming defines a function in terms of itself. Recursion in computer programming.
INTRO2CS Tirgul 6. Understanding the Traceback # in file t.py: def a(L): return b(L) def b(L): return L.len() #should have been len(L) # in the python.
1 Towers of Hanoi Three pegs, one with n disks of decreasing diameter; two other pegs are empty Task: move all disks to the third peg under the following.
Recursion Chapter 2 Objectives Upon completion you will be able to:
Tower of Hanoi problem: Move the pile of rings from one peg to another
CSCE 3110 Data Structures & Algorithm Analysis
Recursion.
Pramada Ramachandran, Assistant Professor, Department of Mathematics,
Chapter 4 Stacks
Recursion in Java December 12, 2005
CSCE 3110 Data Structures & Algorithm Analysis
School of EECS, Peking University
Whiteboardmaths.com © 2004 All rights reserved
Jordi Cortadella Department of Computer Science
CSCE 3110 Data Structures & Algorithm Analysis
Copyright © Cengage Learning. All rights reserved.
ECE 103 Engineering Programming
Notes 9.5 – Mathematical Induction
Tower of Hanoi problem: Move the pile of rings from one peg to another
Copyright © Cengage Learning. All rights reserved.
Recursion.
1A Recursively Defined Functions
Chapter 19: Recursion.
Write the recursive and explicit formula for the following sequence
Problem Solving WEEK 3.
Tower of Hanoi problem: Move the pile of rings from one peg to another
Tower of Hanoi Problem Laboratory Experiment #1 Eltayeb Abuelyaman
Recursively Defined Sequences
Presentation transcript:

When Will The World End “Temple of Brahma” legend from the Indian city of Benares Priests must move 64 gold disks from one end of the temple to the other Disks may only be moved one at a time, and a larger disk may never be placed on a smaller disk There is only one intermediate spot where a disk may be placed. When the last disk is placed on the stack the world will vanish in a clap of thunder.

Origin of “Tower of Hanoi” Edouard Louis, French mathematician, 1883 Tower of Hanoi at MazeWorks

Recursive Pattern Let M = the number of moves to move (n-1) disks to position 2. [M moves] Move disk 1 to position 3. [1 move] Move (n-1) disks to position 3. [M moves] Total number of moves 2M + 1

Number of disks 1 2 3 4 5 Number of moves 1 3 7 15 31

Explicit Pattern Find a pattern. Hint: add 1 to each number of moves Number of moves at n: a(n)=2n-1 Can be proven with induction Hint

When will the World End If it takes 1 second for the monks to move each disk, then the world will end in 264-1 seconds. 1.84 x 1019 seconds. 5.12 x 1015 hours. 5.85 x 1011 years.

When will the World End That’s 585 billion years!!! End Show

Number of disks 1 2 3 4 5 Number of moves 1 + 1 = 2 3 + 1 = 4 7 + 1 = 8 15 + 1 = 16 31 + 1 = 32 Return